I am trying to stop the body from loading using javascript, and then write something on the body element.
I can do this with:
<html>
<head>
<script>
document.write('<!--');
window.onload = function(){
document.body.innerHTML = "123";
}
</script>
</head>
<body>
<script>
alert(1); // This won't show
</script>
</body>
</html>
And this works, the alert
function will never be called.
But the problem is that if there is another comment tag on the head section, such as:
<html>
<head>
<script>
document.write('<!--');
window.onload = function(){
document.body.innerHTML = "123";
}
</script>
<!-- other tag -->
</head>
<body>
<script>
alert(1); // This will now show.
</script>
</body>
</html>
How should I handle this? It is very important that all the content on the body element, won't load. Not just hidden, but not loaded.