Eric Yin Eric Yin - 2 years ago 211
Javascript Question

How to stop page load in html static page

Is there in HTML (javascript) or other static html tech

  • Stop page loading (if browser does not download yet)

  • Stop page rendering (from where the code placed)

  • Stop javascript executed (from where the code placed)

Simply put, is there a code like


To let browser totally ignore whatever below the code.


I understand the browser may already download the whole thing. What I want is, from the code, page should stopped, for example: if I put the code just after
visitor should see blank page, if I put the code in middle of the page, page should be just half like you pressed ESC


As bukko suggested, comments done the trick. But not full, just half
If you put
in html page, the rest will be ignored. And in Javascript


Done the trick.

For about make sense:

Here is how this code make sense: when you page load some offpage script, the script is dynamic. When the script code found something wrong (or match some condition), you have one more option to stop the page from rendering, loading, download...

Answer Source

If you already have html comments on your page, @bukko's solution doesn't fully work. Stuff after the html comment will get rendered normally.

Something else to try is:

document.write('<script type="text/undefined">')

The rest of the document gets interpreted as part of the script tag, and because the script isn't text/javascript, it gets ignored.

Worked for me, thought I'd share it.


I've seen the script trick not work in Chrome.

This does work, but I have not done extensive browser testing:

document.write('<style type="text/undefined">')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download