function init(){init_fckeditor();return postForm.innerHTML; } function restore(obj){init_fckeditor();postForm.innerHTML=obj; } var AutoSaveTime=60; var FileName="http://www.leeglee.cn/CACHE/autosave_df54dcb0b829017d379f43a168b507c1.txt"; var postForm = null; var msg = null; function init_edit(){ postForm = document.edit.txaContent; msg = document.getElementById("msg"); } function init_widgeditor(){ postForm =document.getElementById('txaContentWidgIframe').contentWindow.document.getElementsByTagName('body')[0]; msg = document.getElementById("msg"); } function init_fckeditor(){ postForm =document.getElementById("MyEditor___Frame").contentWindow.frames[0].document.getElementsByTagName('body')[0]; msg = document.getElementById("msg"); } function init_htmlarea(){ postForm =document.getElementById('ta').parentNode.getElementsByTagName('iframe')[0].contentWindow.document.getElementsByTagName('body')[0]; msg = document.getElementById("msg"); } function init_tinymce(){ postForm =document.getElementById('mce_editor_0').contentWindow.document.getElementsByTagName('body')[0]; msg = document.getElementById("msg"); } function init_ewebeditor(){ postForm =document.getElementById('eWebEditor1').contentWindow.document.getElementsByTagName('body')[0]; msg = document.getElementById("msg"); }var ti=AutoSaveTime;function savedraft(){ init(); if (postForm!=null&&typeof(postForm)!=undefined){ var url = "c_autosaverjs.asp"; var postStr = init(); if (postStr){ var ajax = getHTTPObject(); ajax.open('POST', url, true); ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); ajax.onreadystatechange = function(){if (ajax.readyState == 4 && ajax.status == 200) msg.innerHTML = ajax.responseText;}; ajax.send(postStr); ti=-1000; }else{ msg.innerHTML = "无内容"; ti=-1000;} }else{msg.innerHTML = "等待载入或窗体名填写错误";ti=-1000;}}function restoredraft(){ init();if (window.confirm('你确认要恢复么')){ if (postForm!=null&&typeof(postForm)!=undefined){ var url = FileName; var ajax = getHTTPObject(); ajax.open("GET", url+'?random='+Math.random(), true); ajax.onreadystatechange = function() { if (ajax.readyState == 4 && ajax.status == 200) { restore(ajax.responseText); msg.innerHTML ="已恢复"; } } ; ajax.send(null); ti=-1000; }else{msg.innerHTML = "等待载入或窗体名填写错误";ti=-1000;}}}function Viewdraft(){ window.open(FileName,'','');}document.getElementById("msg2").innerHTML =" [查看] [恢复] [保存]";function timer() { ti=ti-1;var timemsg=document.getElementById("timemsg");timemsg.innerHTML = ti+"秒后自动保存";if (ti>=0){window.setTimeout("timer()", 1000);}else{if (ti<=-1000){ti=AutoSaveTime;timer();}else{timemsg.innerHTML = "正在保存...";savedraft();ti=AutoSaveTime;timer();}} }window.setTimeout("timer()", 0); function getHTTPObject() { var xmlhttprequest=false; try { xmlhttprequest = new XMLHttpRequest(); } catch (trymicrosoft) { try { xmlhttprequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { xmlhttprequest = false; } } } return xmlhttprequest; }