Replace a complete HTML document with HTML containing inline scripts
I have the following code that works correctly 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" to the console. The same code doesn't work with firefox, it doesn't run the script, it just prints the text.
(If you are wondering why I need this, you can find it here: https://stackoverflow.com/a/2236266/ ... )
I have tried possible solutions like this: https://stackoverflow.com/a/2999889/ , but they didn't work. Any idea how to do this?
Note. There are many scripts in HTML, for example. bootstrap, jquery, facebook, google, etc., not just one inline script.
source to share
I think there is no way in firefox to replace a complete HTML document with javascript without leaving the actual page. A workaround to reuse the original document and replace only the head and body tags:
$('html').html(html);
does this automatically: it removes the HTML tags, injects the head and body, and loads the scripts.
source to share