javascript - Replace complete HTML document with HTML code containing inline scripts -


i have following code works in chome

<!doctype html> <html> <head>     <meta charset="utf-8"> </head> <body>     <script>     //<![cdata[         !function (){             window.stop();             var html = '<!doctype html>\n<html>\n<head>\n    <meta charset="utf-8">\n</head>\n<body>\n  \<script>console.log("loaded");<\/script>\ntext\n</body>\n</html>';             document.documentelement.innerhtml = html;         }();     //]]>     </script> </body> </html> 

it prints "loaded" in console. same code not work firefox, not run script, prints text.

(if curious why need this, can find here: https://stackoverflow.com/a/30933972/607033 )

i tried possible solutions this: https://stackoverflow.com/a/20584396/607033 did not work. idea how work around?

note: there many scripts in html, e.g. bootstrap, jquery, facebook, google, etc..., not single inline script.

i think there no way in firefox replace complete html document javascript without leaving actual page. workaround reuse original document , replace head , body tags:

$('html').html(html); 

does automatically: strips out html tags, injects head , body , loads scripts.

ref: https://stackoverflow.com/a/1236372/607033


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -