首页 > Web开发 > 详细

js 判断页面加载状态

时间:2016-01-07 18:17:50      阅读:425      评论:0      收藏:0      [点我收藏+]
  //----判断当前页面是否加载状态 开始 ----
        document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法. 
        function subSomething() {
            if (document.readyState != ‘complete‘) //当页面加载状态 
            {
                //----显示遮罩 开始----
                $(".overlay").css({ ‘display‘: ‘block‘, ‘opacity‘: ‘0.8‘ });
                $(".showbox").stop(true).animate({ ‘margin-top‘: ‘300px‘, ‘opacity‘: ‘1‘ }, 200);
                //----显示遮罩 结束----
            }
        }
        //----判断当前页面是否加载状态 结束 ----

页面加载readyState的五种状态 
原文如下: 
0: (Uninitialized) the send( ) method has not yet been invoked. 
1: (Loading) the send( ) method has been invoked, request in progress. 
2: (Loaded) the send( ) method has completed, entire response received. 
3: (Interactive) the response is being parsed. 
4: (Completed) the response has been parsed, is ready for harvesting. 

翻译成中文为
0 - (未初始化)还没有调用send()方法 
1 - (载入)已调用send()方法,正在发送请求 
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容 
3 - (交互)正在解析响应内容 
4 - (完成)响应内容解析完成,可以在客户端调用了

js 判断页面加载状态

原文:http://www.cnblogs.com/foreverfendou/p/5110610.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!