I have a tool which generates some html+javascript code, it shows the code in one div and then shows a preview of what the code displays like in an iframe.
Here's a quick fiddle which shows this... http://jsfiddle.net/Zv4zU/
But the javascript within the iframe never runs even though if you inspect the iframe the javascript is definitely in there. How can I get the javascript to run by itself?
See this jsfiddle for a solution!
Edit: As Jonathan pointed out, I should also post the code here:
var html = "html code <script type='text/javascript'>alert('OK');<\/script>";
$("#myFrame").contents().find("body").html(html);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With