刷新技术经历了大致几个阶段: 一、在html文件头里增加一个键,使该页面在设定的时间后跳转到指定的页面(包括自身); 例如: <meta http-equiv="refresh" content="30"> 二、使用框架然后在js脚本里定时刷新框架内容。 上面两种方式都会重新加载页面,即刷新,给人的感觉不是很好!于是无刷新技术出现了。 三、是对第二种方式的一种变通。 即将众多框架中的一个长宽设置为0,使其不可见,然后通过脚本定时刷新该隐藏框架内容,再将该框架内容“写”到可浏览的框架里。早期的聊天室大多使用了这种技术。 真正意义上实现无刷新技术的还是以下两种技术,它们甚至可以实现局部刷新: 四、xmlhttp技术,可以通过xmlhttp访问asp页面、aspx页面、webservice等。 <script language="javascript"> 五、webservice,使用webservice.htc组件访问web服务。 var obj; function show(result){ 六、remoting,使用remoting也可以实现无刷新技术。因为remoting组件可以提供包括http在内的多种访问方式,当作为http访问时相当于一个webservice。
function re()
{
var http = new activexobject("microsoft.xmlhttp");
http.open("get","../advertisement/3.htm",false);
http.send();
var str = http.responsetext;
t.innerhtml=str;
}
</script>
<span id=t></span>
function init(obj,op,id)
{
obj=obj;
obj.useservice("admin/dataoperation.asmx?wsdl","getbody");
obj.getbody.callservice(show,op,id);
}
obj.innerhtml=result.value;
}