举例:
-----------------------a.html--------------------------
<html>
<Script>
document.write ("马上就会弹出一个小窗口~");
helloWin = open ('b.html','','height=100,width=300');
//helloWin.document.write ("啊呀呀啊呀呀~~");
helloWin.document.title = "欢迎光临";
</Script>
<body>
</body>
</html>
-----------------------a.html--------------------------
-----------------------b.html--------------------------
<html>
<script>
function changeParentBg(color){
opener.document.bgColor = color;
}
</script>
<body onclick = "self.close()">
<input type ="button" onclick = "changeParentBg('red')" value = "红色"/>
<input type ="button" onclick = "changeParentBg('blue')" value = "蓝色"/>
</body>
</html>
-----------------------b.html--------------------------
说明:上面的代码,如果把a.html中的write注释,那么b.html的onclick = "self.close()">方法就可以正常使用,否则无法使用self的close方法关闭窗口,并且b.html中的<input type ="button" onclick = "changeParentBg('red')" value = "红色"/>
<input type ="button" onclick = "changeParentBg('blue')" value = "蓝色"/>这些代码都无法显示
-----------------------a.html--------------------------
<html>
<Script>
document.write ("马上就会弹出一个小窗口~");
helloWin = open ('b.html','','height=100,width=300');
//helloWin.document.write ("啊呀呀啊呀呀~~");
helloWin.document.title = "欢迎光临";
</Script>
<body>
</body>
</html>
-----------------------a.html--------------------------
-----------------------b.html--------------------------
<html>
<script>
function changeParentBg(color){
opener.document.bgColor = color;
}
</script>
<body onclick = "self.close()">
<input type ="button" onclick = "changeParentBg('red')" value = "红色"/>
<input type ="button" onclick = "changeParentBg('blue')" value = "蓝色"/>
</body>
</html>
-----------------------b.html--------------------------
说明:上面的代码,如果把a.html中的write注释,那么b.html的onclick = "self.close()">方法就可以正常使用,否则无法使用self的close方法关闭窗口,并且b.html中的<input type ="button" onclick = "changeParentBg('red')" value = "红色"/>
<input type ="button" onclick = "changeParentBg('blue')" value = "蓝色"/>这些代码都无法显示