简体   繁体   中英

How can child window call a function on its parent window?

I have a local HTML running in IE browser. When the local HTML opens a child window which loads a page on a remote HTTP server. After a few user interactions in the child window, the final remote page runs a JavaScript to close the child window and I would like to call a function in the parent window to pass back some info before closing.

I thought I would be able to simply make the following call in the child window

window.parent.CallbackFunct();

However, the call doesn't work. I did some research and some mentioned that if the parent window loads HTML through file:\\ (which is my case), the child window cannot call parent window functions due to same origin policy.

JavaScript window.opener call parent function

My above link suggests to access all pages through HTTP://, but I cannot. The parent window has to access pages from the local file system.

Is there any way that I can make it work?

您可以通过以下方式从子窗口调用父函数:

window.opener.your_function()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM