Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

javascript - How to stop page load in html static page

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

  • 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

<script>window.StopWhateverBelow()</script>

To let browser totally ignore whatever below the code.

UPDATE

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 <body> visitor should see blank page, if I put the code in middle of the page, page should be just half like you pressed ESC

ANSWER

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

document.write('<!--');

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...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could do window.stop(); for most browsers besides Internet Explorer. For IE, I had to use document.execCommand('Stop');


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...