< body>如何防止加载页面有一堂课 [英] How Prevent to load page if <body> has a class

查看:74
本文介绍了< body>如何防止加载页面有一堂课的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我问这个问题,因为我没有找到任何答案。

我的问题是有任何可能性/方法来防止页面加载/网站负载如果< body> 有一个类< body class =unload> ,页面将停止加载。
我可以通过css 完成此操作,但它会隐藏或不显示。所以我想知道有没有可能/方法来阻止页面加载/停止播放(停止浏览器加载无显示无或隐藏?。



HTML: 小提琴>

 < body class =unload> 
< div class =wrapper>
< ul> <! - 父元素 - >
< li>文字< / li> <! - 儿童1 - >
< li>文字< / li> <! - 儿童2 - >
< li>文字< / li> <! - 儿童3 - >
< li>文字< / li> <! - 儿童4 - >
< li>文字< / li> <! - 儿童5 - >
< / ul>
< / div>
< body>

我的意思是浏览器将立即停止加载,如果 < body> 有一个类< body class =unload> 。任何机构知道如何通过Jquery 。 解读方案

阅读 https://developer.mozilla.org/en-US/docs/Web/API/Window/stop - 这可以做你想做的事

 < body class =unload> 
< script>
if(document.body.classList.contains('unload')){
if(window.stop){//所有邻接的Internet Explorer
window.stop();
}
else if(document.execCommand){// Internet Explorer
document.execCommand('Stop');


//基于注释
setInterval(function(){
if(jQuery('.sly-scroll ul> li,.label- ('body')。addClass('popup');
}
if(document.querySelector(' ('。wrapper')。html('');
}
},1000);
< / script>
< div class =wrapper>
< ul> <! - 父元素 - >
< li>文字< / li> <! - 儿童1 - >
< li>文字< / li> <! - 儿童2 - >
< li>文字< / li> <! - 儿童3 - >
< li>文字< / li> <! - 儿童4 - >
< li>文字< / li> <! - 儿童5 - >
< / ul>
< / div>
< body>

工作小提琴
更好小提琴 for Internet Explorer



感谢@ A.Wolff的Internet Explorer解决方法


Hi i'm asking this question because there are no any answer i have find.
My question is there are any possibility/way to Prevent page load/Site-Load if <body> has a class <body class="unload"> then page will stop loading.
I can do this by css but its become hidden or display none. So i want to know there any possibility/way to Prevent Page load/stop-loding(stop browser Loading) with out display none or hiding ?.

HTML: Fiddle>

<body class="unload">  
   <div class="wrapper">  
     <ul>    <!-- Parent Element -->
     <li>text</li>     <!-- Child 1-->
     <li>text</li>     <!-- Child 2-->
     <li>text</li>     <!-- Child 3-->
     <li>text</li>     <!-- Child 4-->
     <li>text</li>     <!-- Child 5-->
     </ul>
   </div>
 <body>

I mean browser will stop Loading immediately if <body> has a class <body class="unload">.
Any body know how to do this by Jquery. Thanks in advance.

解决方案

having read https://developer.mozilla.org/en-US/docs/Web/API/Window/stop - this may do what you want

<body class="unload">  
    <script>
    if (document.body.classList.contains('unload')) {
        if(window.stop) { // all abut internet explorer
            window.stop();
        }
        else if (document.execCommand) { // internet explorer
            document.execCommand('Stop');
        }
    }
    // based on comments
    setInterval(function() {
        if (jQuery('.sly-scroll ul > li, .label-widget-menu ul > li').length > 4) {
            jQuery('body').addClass('popup');
        }
        if (document.querySelector('html').classList.contains('unload')) {
            jQuery('.wrapper').html('');
        }
    }, 1000);
    </script>
   <div class="wrapper">  
     <ul>    <!-- Parent Element -->
     <li>text</li>     <!-- Child 1-->
     <li>text</li>     <!-- Child 2-->
     <li>text</li>     <!-- Child 3-->
     <li>text</li>     <!-- Child 4-->
     <li>text</li>     <!-- Child 5-->
     </ul>
   </div>
 <body>

working fiddle better fiddle for Internet Explorer

Thanks to @A.Wolff for the Internet Explorer workaround

这篇关于&lt; body&gt;如何防止加载页面有一堂课的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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