Brian
Brian

Reputation: 27392

Call JavaScript function in opener

I need to to trigger a JavaScript function in an opener window by clicking a button in the child.

I thought the following would work, but it is not.

window.opener.MyFunction()

Upvotes: 4

Views: 4939

Answers (4)

shaILU
shaILU

Reputation: 2116

It works for me on IE9. I need to open separate window for a user to upload a doc and on successful upload I must tell opener window to perform some task. Might be other browser you mentioned does not support this.

Upvotes: 0

Shivkant
Shivkant

Reputation: 4619

Try using :

window.onload = function() { MyFunction(); }

Upvotes: -1

Brian
Brian

Reputation: 27392

It turns out that MyFunction() was inside a jQuery document.ready statement. It worked fine after I changed that. Interesting though, window.opener.close() still does not work.

Upvotes: 2

x0n
x0n

Reputation: 52430

Are both windows on the same domain (e.g. foo.com?) It might be blocked due to reasons of cross-site scripting security.

Upvotes: 0

Related Questions