A-A+

window.open获取回调值

2016年03月17日 javascript 暂无评论

We usually use the "open" method in the window object to open a new window in Javascript. However, sometimes you need to change some values in the parent window depending on the changes of the new window elements values or you may need to call a method in the parent window from the child one. To do so, you can use the "opener" property in the window object to access the parent page elements. The following Javascript statement access an input element in the parent window with "txtEmail" ID and update its value:

You can even call a method direct in the parent window from the new opened one:

However, you may get "Access Denied" or "Permission Denied" message when trying to access the "opener" property in the popup window. This usually because you call the window.open with the full path of the pop window:

To resolve this issue, use the relative path of the popup page instead of the full path when opening it and you will be able to safely access the opener property of the window.

标签:

给我留言

Copyright © 前端面试题 保留所有权利.   Theme  Ality 桂ICP备17012235号-1

用户登录