如何从 javascript 找到模式对话框开启器?

发布于 2024-07-25 00:25:19 字数 210 浏览 2 评论 0原文

我有一个打开模式对话框的页面。 在对话框上完成操作后,我想刷新打开页面。 但是,当我使用“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

苍白女子 2024-08-01 00:25:20

如果您查看 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.

帅气尐潴 2024-08-01 00:25:20

模式对话框是一种阻塞功能。 呼叫者等待直到盒子关闭,然后继续。 因此,在调用 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.

世界如花海般美丽 2024-08-01 00:25:19

这就是我从链接中获得的需要

在父项中:

parentVar = "set by parent";
vRv = window.showModalDialog("modalWindow.html",window.self, "");

在模式中:

dialogArguments.parentVar = "set by modal";

PS:不要忘记使用“window.self”设置对开启器的引用

this was what i need that i got from the link

In the parent:

parentVar = "set by parent";
vRv = window.showModalDialog("modalWindow.html",window.self, "");

In the modal:

dialogArguments.parentVar = "set by modal";

PS: Dont forget to set reference to opener with "window.self"

堇年纸鸢 2024-08-01 00:25:19

当我使用 Shadowbox 时我可以访问它。

self.parent.location.reload();

也许这也适合你。

When i use Shadowbox i can access this.

self.parent.location.reload();

Perhaps this works for you also.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文