【问题标题】:when document is loading, stop loading if this condition is not met加载文档时,如果不满足此条件,则停止加载
【发布时间】:2013-09-30 17:19:35
【问题描述】:

当窗口大于 350 时 $(document).ready(function() 停止。

$(document).ready(function(){
if ($(window).width() > 350 ){
alert ("No!!! stop");
// I want to stop loading the page altogether if window is less than 350.
return false;
}
else if ($(window).width() < 350 ) {
alert ("Ok continue.")
}

提前致谢。

【问题讨论】:

  • 请先了解Javajavascript 之间的区别,然后再继续。
  • @SotiriosDelimanolis - 我在这里没有看到任何关于 Java 的提及?我错过了什么吗?
  • @TravisJ 我编辑了它。
  • 我的错,我错误地发布了一个自动生成的标签。谢谢。
  • “停止加载”是什么意思?

标签: javascript jquery html unbind document-ready


【解决方案1】:

$(document).ready(function() 在页面加载后执行。 如果你把你的javascript放在你的身体上,你可以做到这一点,所以它会在页面加载之前执行

<html>
<body>
<script type='text/javascript'>
   //your actions here
   //for example redirect to empty page that says stop your width is too large
   //another solution is to spam alerts() and if there is no alerts reload page to spam more
   //show page with javascript
   //$("body').html('STAPH')
</script>
...
</body>
</html>

我可以喜欢吗?

【讨论】:

    【解决方案2】:

    好的,我刚刚添加了

    $("div").empty(); 
    

    如果窗口大于 350,则只清空所有 div。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多