document.cookie="cookieName=value;expires="+打开网页时间+15秒

解决方案 »

  1.   

    两个文件,test.htm 和 lizi.htm
    ++++===================  test.htm =========
    <html>
    <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <form name="form1" method="post" action="">
      <p>
        <select name="select" onchange="window.open('lizi.htm')">
          <option>1</option>
          <option>2</option>
        </select>
      </p>
      <p>
        <input type="text" name="textfield">
      </p>
    </form>
    <script>
    var str=document.location.search
    var str2=str.split("=")
    document.form1.textfield.value=str2[1];
    </script>
    </body>
    </html>========== lizi.htm ===========
    <html>
    <head>
    <title>无标题文档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script>
    function test(){
    opener.location.href=opener.location+"?form1="+document.form1.textfield.value
    opener.location.reload()
    self.close()
    }
    </script>
    </head><body bgcolor="#FFFFFF" text="#000000">
    <form name="form1" method="post" action="">
      <input type="text" name="textfield">
      <br>
      <input type="submit" name="Submit" value="提交" onclick="test()">
    </form>
    </body>
    </html>
      

  2.   

    当然,对于test.htm文件打开时,文本框出现的undefined,可以采用下面的办法解决
    test.htm
    ===========
    <script>
    var str=document.location.search
    if(str) {
    var str2=str.split("=")
    document.form1.textfield.value=str2[1];
    }
    </script>