我使用window.open打开一个新选项卡。新标签页具有myfunction
在script标签中定义的javascript函数。我想从打开新窗口的窗口中运行该功能。
我怎样才能做到这一点?
谢谢
就像是
var a = window.open("mypage.html", "_blank");
a.myfunction("hi");
编辑
这不起作用。它没有发出警报。
开瓶器
var w = window.open("../scripts/map.php", "_blank");
w.postMessage("The user is 'bob' and the password is 'secret'", "*");
新标签
function receiveMessage(event) {
alert(event.data);
}
window.addEventListener("message", receiveMessage, false);
var a = window.open("mypage.html", "_blank");
a.focus();
a.addEventListener('load', function(){
a.myfunction("hi");
}, true);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句