当前位置: 代码迷 >> Java Web开发 >> 2html页面,js传值有关问题
  详细解决方案

2html页面,js传值有关问题

热度:1688   发布时间:2013-02-25 21:08:56.0
2html页面,js传值问题
有1和2 这两个页面,目标:打开1点击按钮,弹出2页面,input框里输入信息,点击确定,关闭窗口,信息传递给1的input框里,请问如何实现?

------解决方案--------------------------------------------------------
下面是两个页面的代码,纯html+js的,已在IE8上测试验证过。楼主要做的这个是很基本的功能,建议用jQuery的easyUI或extJs等成熟组件,既美观又方便。
1的代码:
HTML code
<html> <head>  <title>1</title>  <Script language="javascript">    function GetRequest() {       var url = location.search;       var theRequest = new Object();       if (url.indexOf("?") != -1) {          var str = url.substr(1);          strs = str.split("&");          for(var i = 0; i < strs.length; i ++) {             theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);          }       }       return theRequest;    }    function PageLoad(){        var Request = new Object();        Request = GetRequest();        if(null == Request['inputTxt'] || "undefined"== Request['inputTxt'])            document.getElementById("txtShow").value = "";        else            document.getElementById("txtShow").value = Request['inputTxt'];    }    function open2(){        window.open("2");    }</Script> </head> <body onload="PageLoad();">  <input type="text" id="txtShow" />  <input type="button" id="btnC" value="Change" onclick="window.open('2');" /> </body></html>
  相关解决方案