jquery.writeCapture.js - Now with 60% more magic!

I've gone ahead and written a jQuery plugin for writeCapture.js. I've reduced the problem to making one extra call in the chain and then the voodoo black magic takes over and you can't go wrong. Here's a kitchen sink example:


In this context, "dangerous" HTML is any HTML that does or could contain a script tag that uses document.write, aka, the evil method. The implementation details are wonderfully complicated, but I've made the usage so simple that any code monkey can just chain whatever they like off of a call to writeCapture() and everything will be perfectly "safe". e.g., document.write will not destroy the application and all the content will show up where it is supposed to. So enjoy.

EDIT: the comments here aren't a good place to ask for help. You can get help through GitHub.


Jasper said...

Hi Noah,

First of all, I would like to thank you for creating writeCapture. I have been solving our third-party tags problem for over 2 weeks now ( good thing my boss has lots of patience :) ).

The next step for me is to drop jQuery dependency. However, I am clueless on how to use writeCaptureSupport provided in nolib-support.js. The sections "Convenience Functions" and "nolib-support" in the documentation doesn't provide much help.

Any hints or ideas would be very much appreciated.


noah said...

Hi Jasper,

I've clarified the documentation a bit. Thanks for the feedback. You can run the library without jQuery by including Then just follow the examples in the readme. Please message me on github or open an issue if you have anymore trouble.

Dmitry said...

Hi Noah,

First of all, I wanted to thank you for your great job. I'm using it for loading OpenX ads after page loaded in order to avoid iframe usage. It works great for most of banners, however for some banner types it puts ad outside of desired container, I assume that there may be some function in script that causes it. It would be awesome if you could take a quick look at the issue and suggest at least direction where I should look for. Here is the test page ( and here is the page with iframe This is the ad

Thank you very much,

ChandraShekhar said...

Hi Noah,

Thanks for creating writeCapture.js.
It works very well to load ads after page load in FF and google chrome..
But in IE the ads are not changing at all.It only blinks the ad div and shows the same ad.

I have checked the readme for writeCapture.js but not yet able to resolve the issue in IE.

Can you please suggest what need to be done for it.

Rintu said...

Hi Noah, Thanks for the wonderful piece of code. But I am facing issue when the document.write(myscript) return iframe content which contain html, head and body inside, the layout of my page is broken and the div containing iframe is not appending in the correct div, instead it is going anywhere behind some "script" tag. I noticed that when we are using $('#divId').writeCapture.html("my script ") and if some script tag after that div (id='divId') is there then the ifram content is not correctly append in that div, instead it is partially appended and the iframe content go and append after the script so my page layout is broken.