【www.gdgbn.com--网页配色】
ajax数据定时自动保存方法
window.onload=function(){var txtobj = document.getelementbyid("txt1");
var spanobj = document.getelementbyid("s1");//自动保存
txtobj.addbehavior("#default#userdata");var savetimer= setinterval(function(){
txtobj.setattribute("ovalue",txtobj.value);
txtobj.save("saveddata");spanobj.innertext="数据保存于:"+(new date());
settimeout(function(){
spanobj.innertext="";
},1000);},10000); //每分钟保存一次
document.getelementbyid("btn1").attachevent("onclick",function(){
clearinterval(savetimer); //取消保存
txtobj.removeattribute("ovalue");
});document.getelementbyid("btn2").attachevent("onclick",function(){
txtobj.load("saveddata");
alert(txtobj.getattribute("ovalue"));
//txtobj.value = txtobj.getattribute("ovalue");
});
};</script>