|
javascript控制cookies及在跳出本页给出提示,是否放弃操作!(3) } else { /**//* this sets the value to true and nothing else will happen, the user will be able to log on*/ document.Form1.cookieexists.value ="true" } } /**//* Set a cookie to be sure that one exists. Note that this is outside the function*/ document.cookie = 'killme' + escape('nothing')
</script> <BODY onbeforeunload="RunOnBeforeUnload()" id="Posts"> <FORM Name="Form1" id="Form1"> <input type="text" name="cookieexists" value="false"> </FORM> <a href="test.html">中微家校通</a>
</BODY> </HTML> <SCRIPT LANGUAGE="JavaScript"> <!-- g_blnCheckUnload = true; function RunOnBeforeUnload() { if (g_blnCheckUnload) { window.event.returnValue = 你确是要放弃操作吗?'; } } //--> </SCRIPT>
2.html(简单的操作cookies)
<html> <head> <title> 新文档 </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content="FLASHSoft"> <meta name="Keywords" content=""> <meta name="Description" content="FlashSoft"> <meta http-equiv="Content-Type" content="text/html;charset=gb2312"> </head> <body> <script language="JavaScript" type="Text/JavaScript"> <!-- // 实在懒得写了,为了减少字节量 //添加和获得都已经写好了,删除,你只要把时间改为-1就可以了,懒得封装了,实在无意义[代码moz兼容,值得一提,moz跟ie不是一个地方存cookie的] function Cookie(){ this.SetValue=function(name,value,hours,path,domain,secure){ var str=new String(); var nextTime=new Date(); nextTime.setHours(nextTime.getHours()+hours);
|