A method of automatic time saving for AJAX data
Window.onload=function () {
var txtobj = document.getElementById (' txt1 ');
var spanobj = document.getElementById (' s1 ');
Automatically save
Txtobj.addbehavior ("#default #userdata");
var savetimer= setinterval (function () {
Txtobj.setattribute (' Ovalue ', txtobj.value);
Txtobj.save (' Saveddata ');
spanobj.innertext= ' data saved in: ' + (new date ());
settimeout (function () {
Spanobj.innertext= ';
},1000);
},10000); Save once per minute
document.getElementById (' btn1 '). attachevent (' onclick ', function () {
Clearinterval (Savetimer); Cancel Save
Txtobj.removeattribute (' Ovalue ');
});
document.getElementById (' btn2 '). attachevent (' onclick ', function () {
Txtobj.load (' Saveddata ');
Alert (Txtobj.getattribute (' Ovalue '));
Txtobj.value = Txtobj.getattribute (' Ovalue ');
});
};
</script>
<body>
<span id= "S1" style= "color:red;" ></span>
<p/>
<textarea height= "style=" height:500px;width:500px; id= "Txt1" >
</textarea>
<p/>
<input type= "button" id= "BTN1" value= "Stop Saving"/>
<input type= "button" id= "btn2" value= "Get Saved value"/>
</body>