oScript.type = "text\/javascript"
oScript.onerror = loadError
oScript.onload = fOnload
document.currentScript.parentNode.insertBefore(oScript, document.currentScript)
oScript.src = sSrc
使用这个HTMLScriptElement对象的onload函数可以判断加载完毕,用onerror判断加载失败。
代码如下:复制代码 代码如下:
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 response is being parsed.
4: (Completed) the response has been parsed, is ready for harvesting.