用JS检测页面加载的不同阶段状态
这可以通过用document.onreadystatechange的方法来监听状态改变, 然后用document.readyState == “complete”判断是否加载完成。
可以采用2个div,其中一个在前面,一个在后面,前面的先显示,里面放一个页面正在加载中的小图片,小flash都可以。
后面的div开始加载内容,在页面上随时监测加载是否完毕,如果加载完毕,将前面的div隐藏,后面的div提到前面来即可。
document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法. function subSomething() { if(document.readyState == “Loaded”) //当页面加载状态 {
//Load提示第一个div隐藏掉
//将Html显示
}
页面加载readyState的五种状态 原文如下:
0: (Uninitialized) the send( ) method has not yet been invoked.
0 - (未初始化)还没有调用send()方法
1: (Loading) the send( ) method has been invoked, request in progress.
1 - (载入)已调用send()方法,正在发送请求
2: (Loaded) the send( ) method has completed, entire response received.
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
3: (Interactive) the response is being parsed. 4: (Completed) the response has been parsed, is ready for harvesting.
3 - (交互)正在解析响应内容
4: (Completed) the response has been parsed, is ready for harvesting.
4 - (完成)响应内容解析完成,可以在客户端调用了