Closed beest closed 14 years ago
Can you post the code you're using? writeCapture doesn't keep any internal state related to the scripts being sanitized. The only thing I can think of is that something being sanitized is throwing an error.
None the less, if you add this to the self
object in the bottom of writeCapture, you can call it and it should be just like writeCapture never ran:
reset: function() {
GLOBAL_Q = new Q();
},
Thanks for the reply - will give this a go and report back.
It's difficult to post the full code as it's part of a HUGE project... But here is a piece of code I'm trying to writeCapture (from WidgetBox):
<script type="text/javascript" src="http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js"></script><script type="text/javascript">if (WIDGETBOX) WIDGETBOX.renderWidget('eae07b24-2422-4cbc-baa2-457053c43c6c');</script><noscript>Get the <a href="http://www.widgetbox.com/widget/flickr-slideshow-pricew">Flickr User Slideshow</a> widget and many other <a href="http://www.widgetbox.com/">great free widgets</a> at <a href="http://www.widgetbox.com">Widgetbox</a>! Not seeing a widget? (<a href="http://docs.widgetbox.com/using-widgets/installing-widgets/why-cant-i-see-my-widget/">More info</a>)</noscript>
And I'm using writeCapture like this:
container.writeCapture().html(content); // where content is the above code
Good news - this is a case of RTFM on my part!
When I debugged the script tags above, the WidgetBox code creates a dynamic element and then injects code into it. This needed the proxyGetElementById option turned on for it to work properly.
Thanks for the help here. Will keep hammering writeCapture over the coming weeks and will feedback to you with any tweaks.
Simon @ BaseKit
I'm having problems capturing the same code dynamically more than once. That is, if I writeCapture some script tags once, they work OK, but if I try to writeCapture the identical script tags again then I get a blank output...
I've tried this with several different scripts, and it seems to be an issue with the writeCapture, rather than the scripts themselves. The scripts all work with writeCapture once successfully.
The context of this issue is that we allow users to paste in code within a page in BaseKit. They can edit the code live in a textarea, and when they click save it passes the contents through writeCapture again and injects the sanitized output into the page. This works once but if I click save again, then the content is lost.
Is there any way to clear writeCapture to enable it to capture the same script twice?
Thanks, Simon @ BaseKit