I open a new tab using window.open. The new tab has a javascript myfunction
function in it defined in a script tag. From the window that opens the new window, I want to run that function.
How can I do that?
Thanks
Something like
var a = window.open("mypage.html", "_blank");
a.myfunction("hi");
EDIT
This isn't working. Its not doing the alert.
opener
var w = window.open("../scripts/map.php", "_blank");
w.postMessage("The user is 'bob' and the password is 'secret'", "*");
new tab
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);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments