怎么用javascript实现两个HTML页面传值问题

我想让一个html中的<input>的value里的值传到另一个页中的一个DIV里怎么办呀?

例如

a.htm:

<form action="b.htm" >
<input name="q" type="text" value=""  />
<input type="submit" value="提交" id="" />
</form>

b.htm

<html>
<body>
<div id="qbox"></div>
<script type="text/javascript">
function getArgs() { 
    var args = {};
        var query = location.search.substring(1);
         // Get query string
    var pairs = query.split("&"); 
                    // Break at ampersand
     for(var i = 0; i < pairs.length; i++) {
            var pos = pairs[i].indexOf('=');
             // Look for "name=value"
            if (pos == -1) continue;
                    // If not found, skip
                var argname = pairs[i].substring(0,pos);// Extract the name
                var value = pairs[i].substring(pos+1);// Extract the value
                value = decodeURIComponent(value);// Decode it, if needed
                args[argname] = value;
                        // Store as a property
        }
    return args;// Return the object 
 }
var str =getArgs();
alert(str['q']);//和input的name对应取值,
document.getElementById("qbox").innerHTML = str['q'];//然后赋值给DIV
</script>
</body>
</html>

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-23
window.opener.document.getElementById("div").innerHTML=document.getElementById("input").value追问

能稍微详细点吗?
只需要写两个html简单的演示一下,谢谢

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网