如何从 javascript 找到模式对话框开启器?
我有一个打开模式对话框的页面。 在对话框上完成操作后,我想刷新打开页面。 但是,当我使用“openDialog”打开弹出窗口时,我无法使用弹出页面上的 window.opener 访问开启器。 当我想访问时它显示“未定义”。 (在这种情况下我不想使用“popup”方法。顺便说一句,我希望它是一个对话框。使用“popup”是我的第二个计划。)
摆脱这个问题的最佳实践是什么?
I have a page that opens a modal dialog. After the operations done on dialog I want to refresh the opener page. But when I open the popup by using "openDialog" I cannot access to the opener by using window.opener on popup page. It appears "undefined" when I wanted to access. (I dont want to use "popup" method in this case. I want it to be a dialog by the way. using "popup" is my second plan.)
What is the best practice to get rid off this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您查看 https://developer.mozilla.org/En/DOM/Window。 openDialog 你会发现你可以通过传递模态参数来使对话框成为模态对话框,这样直到对话框完成后它才会返回,此时你可以重新加载父页面。
if you look at https://developer.mozilla.org/En/DOM/Window.openDialog you'll see that you can make the dialog box modal by passing the modal argument through, that way it wont return until the dialog is finished, at that time you can reload parent page.
模式对话框是一种阻塞功能。 呼叫者等待直到盒子关闭,然后继续。 因此,在调用 open 之后在原始脚本中进行刷新是一个简单的事情
对话框。
例如,假设您有一个带有网格的页面。 您有一个添加按钮来打开模式对话框,并且需要网格刷新自身(或刷新页面,问题是相同的)。
这是打开模式对话框的伪代码,然后刷新网格
替换 grid.Refresh(); 无论您想要发生什么操作,它将在对话框关闭后执行。
a modal dialog box is a blocking function. the caller waits until the box is closed, then resumes. Therefore, it is a simple matter of doing the refresh in the script of origin AFTER the call to open
the dialog.
For example, let's say you have a page with a grid. You've got an add button to open a modal dialog, and you need the grid to refresh itself (or refresh the page, the problem is the same).
HEre's pseudo code to open modal dialog, then refresh the grid
replace grid.Refresh(); with whatever action you want to happen, it will execute AFTER the dialog box is closed.
从模式对话框修改父数据
从模态子窗口刷新父窗口
Modifying parent data from modal dialog
Refresh parent window from modal child window
这就是我从链接中获得的需要
在父项中:
在模式中:
PS:不要忘记使用“window.self”设置对开启器的引用
this was what i need that i got from the link
In the parent:
In the modal:
PS: Dont forget to set reference to opener with "window.self"
当我使用 Shadowbox 时我可以访问它。
也许这也适合你。
When i use Shadowbox i can access this.
Perhaps this works for you also.