jQuery: Set the content of an empty IFRAME

I had to do some JS trickery to implement a preview feature by posting via AJAX without having to reload the current page.

The problem I ran into was displaying the output into an iframe.

Assuming the HTML is:

<iframe id='preview-iframe' src="about:blank"></iframe>

We can use this jQuery command to inject the HTML into the iframe.


Update (18/01/13): Thanks Nikri for the IE about:blank fix!


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog