Reputation: 26341
Is this possible?
var win = window.open(url);
win.func = function() {
win.someFunc();
// ...
}
Then I want func
to be called, when win
's scripts and DOM is fully loaded. jQuery solution will be good too.
Upvotes: 0
Views: 330
Reputation: 3865
Why not just use this in your html that loads with window.open.
jQuery(document).ready(function() {
someFunc();
});
UPDATE: If you have to pass parameters than you can, as TJHeuvel stated, from ready function call function from opener window that calls someFunc.
Or you can have "global" variable, in your main window, that holds your parameters than in your someFunc() you can access it like
window.opener.myparameters.param1;
window.opener.myparameters.param2;
assuming that myparameters has param1 and pram2 fields.
UPDATE: examples
myparameters = new Object();
myparameters.param1 = "1";
myparameters.param2 = "2";
or
myparameters = {param1: "1", param2: "2"};
Upvotes: 1
Reputation: 12618
You can have the child window call a parent function onload. As such:
window.onload = function()
{
window.opener.ChildLoaded(this);
}
Upvotes: 0