这题目是转载别人的。因为遇到的是同样的问题。所以直接把他的题目拷过里问了。我在编写HTML页面的时候写了两个页面
具体的代码如下
父页面:
<html >
<head >
<title > Opener</title>
<script type ="text/javascript" >
function test() {
querywin = window.open('link.htm');
}
</script>
</head>
<body >
<input type="button" onclick="test()" value="test"/>
<textarea id="shit"></textarea>
</body>
</html>子页面
<html >
<head >
<title > </title>
<script type ="text/javascript" >
function passToOpener(color)
{
window.opener.document.getElementById("shit").value = color ;
window.close();
}
</script>
<center>choise your fav color <br />
<input type ="button" onclick ="passToOpener('red')" value ="red" />
<input type ="button" onclick ="passToOpener('blue')" value ="blue" />
</center>
</head>
</html>我打开a.htm之后点击test按钮,弹出子窗口,然后将子窗口的值回填到父页面,目前测试中IE,Firefox可以支持,在chrome下不可以。不知道是不是我代码写的有问题,还是没有兼容。。
具体的代码如下
父页面:
<html >
<head >
<title > Opener</title>
<script type ="text/javascript" >
function test() {
querywin = window.open('link.htm');
}
</script>
</head>
<body >
<input type="button" onclick="test()" value="test"/>
<textarea id="shit"></textarea>
</body>
</html>子页面
<html >
<head >
<title > </title>
<script type ="text/javascript" >
function passToOpener(color)
{
window.opener.document.getElementById("shit").value = color ;
window.close();
}
</script>
<center>choise your fav color <br />
<input type ="button" onclick ="passToOpener('red')" value ="red" />
<input type ="button" onclick ="passToOpener('blue')" value ="blue" />
</center>
</head>
</html>我打开a.htm之后点击test按钮,弹出子窗口,然后将子窗口的值回填到父页面,目前测试中IE,Firefox可以支持,在chrome下不可以。不知道是不是我代码写的有问题,还是没有兼容。。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货