如何在html静态页面中停止页面加载 [英] How to stop page load in html static page

查看:2018
本文介绍了如何在html静态页面中停止页面加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML(javascript)或其他静态html技术
可以:


  • 停止页面加载(如果浏览器还没有下载)

  • 停止页面渲染(放置代码的位置)

  • 停止执行JavaScript(放置代码的位置)



  • 简单地说,是否有像

    这样的代码?

     <脚本> window.StopWhateverBelow()< /脚本> 

    让浏览器完全忽略代码下面的内容。



    更新

    据我所知,浏览器可能已经下载了整件事情。我想要的是,从代码中,页面应该停止,例如:如果我把代码放在< body> 访问者的后面,应该看到空白页面,代码在页面中间,页面应该只是你按下的一半 ESC



    ANSWER



    正如bukko所建议的,评论完成了这个诀窍。但不是全部,只有一半
    如果你在html页面中放置<! - ,其余的将被忽略。在Javascript中

      document.write('<! - '); 

    完成这项技巧。

    有意义:



    以下代码是如何理解的:当您加载一些offpage脚本时,脚本是动态的。当脚本代码发现错误(或符合某些条件)时,您还有一个选项可以停止页面的渲染,加载,下载...... 解决方案

如果您的网页上已经有html评论,则@ bukko的解决方案无法正常工作。



其他要尝试的是:

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

文档的其余部分被解释为脚本标记的一部分,并且由于该脚本不是 text / javascript ,因此将被忽略。



为我工作,以为我会分享它。




编辑



我看到脚本技巧在Chrome中无法使用。



这确实有效,但我还没有做过大量的浏览器测试:

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


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

解决方案

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.


Edit

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">')

这篇关于如何在html静态页面中停止页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆