想实现的是一个页面设置3秒自动刷新,在打开输入框的层时就不刷新<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>111</title>
<script language="JavaScript" type="text/javascript">
   function myrefresh(){
      window.location.reload();
   } 
   var obj=document.getElementById("closeshow");
   if(obj.style.display=="none"){
       setTimeout('myrefresh()',30000);
   }
   function showclose() {
     var obj=document.getElementById("closeshow");
  if(obj.style.display=="none"){
  obj.style.display="block";
  }else{
  obj.style.display="none";
  }
   }
</script>
</head>
<body>
<div id="UpdatePanel2">
<table>
                    <tr>
                        <td width="100" height="30">在线问答:</td>
                        <td height="26" >
                            <a href="javascript:;"  onclick="showclose();">【我要提问】</a></td>
      <td width="150" height="26" align="right" nowrap="nowrap" style="padding-right: 10px;">
      </td>
                        <td width="100" height="26" align="right" nowrap="nowrap" style="padding-right: 10px;">
                            <A href="javascript:location.reload();"><STRONG>刷 新</STRONG></A></td>
                    </tr>
</table>
</div>
        <div id="closeshow" style="display: none;">
            <div id="closewindow">
                <div class="msg_block">
                    <table width="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="bk2">
                        <tr>
                            <td width="561" background="playimg/title_bg.jpg">
                                <strong>&nbsp;我要提问</strong></td>
                            <td width="37" align="right" background="playimg/title_bg.jpg">
                                <a href="javascript:;" onclick="showclose();">关闭</a>&nbsp;</td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" valign="top" style="padding: 10px;">
<form action="" method="post" name="saypl" id="saypl">
   <label><textarea name="saytext" rows="2" cols="20" id="saytext" style="height:97px;width:416px;"></textarea></label>
   <p><label>&nbsp;<input name="imageField" type="submit" id="imageField" value=" 提 交 " />
   </label></p>
</form>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div id="graydiv">
            </div>
        </div>
</body>
</html>

解决方案 »

  1.   

    function myrefresh() {
                window.location.reload();
            }
            var a;
            var obj;
            window.onload = function () {
                alert('a');
                obj = document.getElementById("closeshow");
                alert(obj.style.display);
                if (obj.style.display == "none") {
                    a = setInterval('myrefresh()', 3000);
                }        }
            function showclose() {
                if (obj.style.display == "none") {
                    obj.style.display = "block";
                    clearInterval(a);
                    
                } else {
                    obj.style.display = "none";
                    a = setInterval('myrefresh()', 3000);
                }
            }
    这样?
      

  2.   

    你要实现的是 每隔3秒自动刷新吧。
    setInterval(function(){},3000)
    //-------------------------------------------------------------------------
    <script language="JavaScript" type="text/javascript">
     var win = null;
      function myrefresh(){
      window.location.reload();
      } 
      var obj=document.getElementById("closeshow");
      if(obj.style.display=="none"){
          win = setInterval('myrefresh()',30000);
      }
      function showclose() {
      var obj=document.getElementById("closeshow");
      if(obj.style.display=="none"){
      obj.style.display="block";
           clearInterval(win)
      }else{
      obj.style.display="none";
         win = setInterval('myrefresh()',30000);
       
      }
      }
    </script>