onreadystatechange事件的用法
2010-12-09 16:10
921 查看
document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法.
function subSomething()
{
if(document.readyState == "complete"){ //当页面加载状态为完全结束时进入
//你要做的操作。
}
}
<script type="text/javascript">
var xmlHttp;
//创建一个XmlHttpRequeset对象
function createXMLHttpRequest()...{
if(window.ActiveXObject)...{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)...{
xmlHttp = new XMLHttpRequest();
}
}
//开始一个请求
function startRequest()...{
createXMLHttpRequest();
xmlHttp.onreadystatechange = handlestatechange;
xmlHttp.open("GET", "SimpleRespose.xml", true);
xmlHttp.Send(null);
}
function handlestatechange()...{
if(xmlHttp.readyState == 4)...{//描述一种"已加载"状态;此时,响应已经被完全接收。
if(xmlHttp.status == 200)...{//200表示成功收到
alert("The Server Replied with:" + xmlHttp.responseText)
}
}
}
</script>
function subSomething()
{
if(document.readyState == "complete"){ //当页面加载状态为完全结束时进入
//你要做的操作。
}
}
<script type="text/javascript">
var xmlHttp;
//创建一个XmlHttpRequeset对象
function createXMLHttpRequest()...{
if(window.ActiveXObject)...{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)...{
xmlHttp = new XMLHttpRequest();
}
}
//开始一个请求
function startRequest()...{
createXMLHttpRequest();
xmlHttp.onreadystatechange = handlestatechange;
xmlHttp.open("GET", "SimpleRespose.xml", true);
xmlHttp.Send(null);
}
function handlestatechange()...{
if(xmlHttp.readyState == 4)...{//描述一种"已加载"状态;此时,响应已经被完全接收。
if(xmlHttp.status == 200)...{//200表示成功收到
alert("The Server Replied with:" + xmlHttp.responseText)
}
}
}
</script>
相关文章推荐
- document.onreadystatechange事件的用法
- document.onreadystatechange事件的用法分析
- document.onreadystatechange事件的用法分析 判断页面加载后再执行脚本
- document.onreadystatechange事件的用法
- ajax-onreadystatechange 事件
- requireJS&seaJS模块加载器原理:<script>标签加载外部js文件用到的onload、onerror和onreadystatechange事件
- Ajax里的onreadystatechange事件
- AJAX - onreadystatechange 事件
- AJAX - onreadystatechange 事件
- AJAX - onreadystatechange 事件
- AJAX入门 之 XMLHttpRequest 状态与 onreadystatechange 事件(三)
- onreadystatechange()事件
- AJAX - onreadystatechange 事件
- AJAX - onreadystatechange 事件
- AJAX - onreadystatechange 事件
- 关于绑定onreadystatechange事件
- AJAX - onreadystatechange 事件
- 加js库和css库| jQuery hover()用法 |document.onreadystatechange |get和post
- AJAX - onreadystatechange 事件