设置一个cookie用作计时,判断时间差

解决方案 »

  1.   

    同意ttyp(愿赌服输)的方法,不过我认为使用SESSION变量是否更好?给个大概的思路,楼主可以参考一下:1.先判断是否有新消息2.如果有,则创建一个SESSION变量,并将当前时间放入此变量,然后用当前时间与此变量中的值进行比较,如果超过了某一个值,(比如半小时==),则播放某一个声音文件3.设置此网页的自动刷新时间为上面比较的值,比如上面设置为半小时,则这里也设置为半小时。
      

  2.   

    ---------test1.html---------------------------------------------
    <html>
    <body>
    <iframe id=aaa src="test2.html" refreshTimes=0 ></iframe><br>
    请注意iframe里有一个refreshTimes的属性。
    </body>
    </html>---------test2.html---------------------------------------------
    <html>
    <head>
    <meta http-equiv="Refresh" content="2">
    <meta content="text/html;charset=gb2312" http-equiv="Content-Type">
    <script language=javascript>
    if(true)//有新信息
    {
      if(window.top.document.all.aaa.refreshTimes%10==0)//如果在十次刷新之内己有过alert,则此if为false;
      {
        alert("有新信息。");
        window.top.document.all.aaa.refreshTimes=window.top.document.all.aaa.refreshTimes*1+1;
      }
      else 
        window.top.document.all.aaa.refreshTimes=0;
    }
    </script>
    </head>
    <body>自动刷新页面。存在于id为aaa的iframe中</body>
    </html>