用cookie实现记住内容?
程序代码:
<html> <head> <title> 用cookie实现可记住表单 </title> <!--脚本部分--> <script> function read_cookie(key){ var str,arry; str=document.cookie; arry=str.replace(/*;*/g,";").split(";"); key=escape(key)+"="; for (i=0;i<arry.length;i++){ if(arry[i].indexOf(key)==0){ return(unescape(arry[i].split("=")[i])); } } } function write_cookie(key,value,cookiDomain,cookipath,cookieTimr,targetwindow) var strAppendix=""; strAppendix += cookiDomain?";domain="+cookiDomain:""; strAppendix += cookipath?";path="+cookipath:""; strAppendix += expireTime?";expire="+expireTime:""; targetwindow=targetwindow? targetwindow:top; targetwindow.document.cookie=excape(key)+"="+excape(value)+strAppendix; } function loadDate(){ if(read_cookie("txt3"))$("txt3").value=read_cookie("txt3"); if(read_cookie("txt4"))$("txt4").value=read_cookie("txt4"); } function saveDate(){ write_cookie("txt3",$("txt3").value); write_cookie("txt4",$("txt4").value); } function $(str){return(document.getElementById(str));} </script> </head> <body style="overflow:auto;" onload="loadDate";onunload="saveDate";> <from> <table> <tr> <td>普通文本框:</td> <td><input id="text1"></td> </tr> <tr> <td>普通文本框1:</td> <td><input id="text2"></td> </tr> <tr> <td>普通文本框2:</td> <td><input id="text"></td> <tr> <td>普通文本框:</td> <td><input id="text2"></td> </tr> <tr> <td>可以记住内容文本框:</td> <td><input id="text3"></td> </tr> <tr> <td>可以记住内容文本框2:</td> <td><input id="text4"></td> </tr> <td colspan="2"> <input name="sumbit" value="提交"> <input name="rest" value="重填"> <input name="button" value="查看cookie" onclick="alert(document.cookie);"> </body> </html>我是菜鸟一个,对于调试程序很差劲,希望大家能帮我看看这个程序那里出错?
如图:
问题:提交和重填按钮没反应?