开发者

Call JavaScript function in opener

开发者 https://www.devze.com 2022-12-15 22:28 出处:网络
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.

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.ope开发者_开发技巧ner.MyFunction()


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.


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


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.


Try using :

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

0

精彩评论

暂无评论...
验证码 换一张
取 消