Embedded HTML <script> tag
Can the script tag be included in a variable?
HTML
<iframe id="myFrame" src="about:blank"></iframe>
CSS
iframe {margin:20px;}
JavaScript
var aValidDoc = '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title></title><style type=\"text/css\">@media screen{html,body{margin:0;padding:0;height:100%;width:100%}p{margin:15px;}}</style></head><body><p>This is the content of the dynmic document.</p><script>alert(\"Welcome\")<\/script><body></html>';
// below line
// <script type="text//javascript"><\/script>
var oIframe = $('myFrame');
var iframeDoc = (oIframe.contentWindow.document || oIframe.contentDocument);
iframeDoc.open();
iframeDoc.write(aValidDoc);
iframeDoc.close();