我正在尝试在窗口加载时打开警告框。这就是我所拥有的:
var imawindow = window.open("http://google.com");
imawindow.onload() = function () {
alert("hey");
}
我做错了什么?提前谢谢!
答案 0 :(得分:0)
在分配之前不应该执行它。删除()
。如果您想呼叫呼叫者的alert
,请使用window.opener
:
imawindow.onload = function () {
window.opener.alert("hey");
}
这应该尊重相同的域名政策。调用窗口应该是域中的相对页面。您不能从http://www.google.com/
拨打http://www.facebook.com/
。但是,如果index.html
和hello.html
来自同一个域,请index.html
和hello.html
,您可以http://example.com/index.html
上的http://example.com/hello.html
拨打电话}
答案 1 :(得分:0)