tags:

views:

92

answers:

3

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()
A: 

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

x0n
Sam domain. In fact they are both included in the same file with a GET Variable used to distinguish
Brian
+1  A: 

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.

Brian
You should accept your own answer, there's a badge for that. ;) And I believe Chrome (and other browsers) specifically will not let you close windows that were not opened by a script.
Rob Van Dam
A: 

Try using :

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

Shivkant