主页面:
1.html
<button id="button1" οnclick="window.open('1.html','name','height=200,width=150');"></button>
<script>
var newwindow = '';
function popitup(url) {
if (!newwindow.closed && newwindow.location) {
newwindow.location.href = url;
}
else {
newwindow=window.open(url,'name','height=200,width=150');
if (!newwindow.opener) newwindow.opener = self;
}
if (window.focus) {newwindow.focus()}
return false;
}
popitup('2.html');
</script>
弹出页面:
<html>
<body>
2.html<br/>
<button οnclick="opener.button1.value='new value'"></button>
<body>
</html>
解释:
主要应用opener定位弹出窗口的父窗口。
1.html
<button id="button1" οnclick="window.open('1.html','name','height=200,width=150');"></button>
<script>
var newwindow = '';
function popitup(url) {
if (!newwindow.closed && newwindow.location) {
newwindow.location.href = url;
}
else {
newwindow=window.open(url,'name','height=200,width=150');
if (!newwindow.opener) newwindow.opener = self;
}
if (window.focus) {newwindow.focus()}
return false;
}
popitup('2.html');
</script>
弹出页面:
<html>
<body>
2.html<br/>
<button οnclick="opener.button1.value='new value'"></button>
<body>
</html>
解释:
主要应用opener定位弹出窗口的父窗口。