用document.onreadystatechange的方法來監聽狀態改變,
然後用document.readyState == “complete”判斷是否加載完成
代碼如下:
document.onreadystatechange = subSomething;//當頁面載入狀態改變的時候執行這個方法.
function subSomething()
{
if(document.readyState == “complete”) //當頁面載入狀態
myform.submit(); //表單提交
}
頁面載入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 responseed being preceived. 4: (Completed) the response has been parsed, is ready for harvesting.
翻譯成中文為
: 0 - (未初始化)還沒有呼叫send()方法
1 - (載入完成)send()方法,正在傳送請求
2 - (載入完成)send()方法執行完成,已經接收到全部回應內容
3 - (互動)正在解析回應內容
4 - (完成)回應內容解析完成,可以在客戶端呼叫了