我正在和IE9一起工作。
不会有跨域的问题,因为我要从页面的相同域加载到弹出窗口中的页面。
发布于 2012-12-12 08:00:40
就像科里说的,使用window.opener来获取父窗口的window。看看这个:
http://jsfiddle.net/Dmnqk/
function openPopup() {
var w = window.open("", "");
w.document.open();
w.document.write("<script type='text/javascript'>window.opener.parentWindowFunction();<\/script>");
w.document.close();
}
function parentWindowFunction() {
alert("called");
}当然,我使用document.open/write/close只是为了创建我自己的页面,该页面调用父窗口的函数(从技术上讲,它实际上应该有<html><head></head><body>SCRIPT HERE</body></html>。你弹出的页面只需要调用window.opener.parentWindowFunction即可。
发布于 2012-12-12 08:03:09
您可以使用window.opener访问打开弹出窗口的页面的全局(window)名称空间中的函数:
开场白
function functionFromOpener() {
return "wharrgarbl";
}弹出窗口
alert(window.opener.functionFromOpener());强制jsFiddle示例:http://jsfiddle.net/9yLu2/1/
也就是说,我认为使用页面中的DHTML对话框是一个更好的主意。(或者可能是浏览器窗口不能调整大小/没有地址栏,这让我很恼火。)
https://stackoverflow.com/questions/13830518
复制相似问题