简体   繁体   English

如何使这个 JavaScript 弹出窗口模态化?

[英]How to make this JavaScript popup window modal?

This is working well for me, but I need to make it modal so it doesn't get lost behind the main app screen.这对我来说效果很好,但我需要使它成为模态,这样它就不会在主应用程序屏幕后面丢失。 Is there a way to easily make this screen modal?有没有办法轻松地使这个屏幕模态化?

string url = "EditTables.aspx?title=Edit Asset Classifications&prompt=Classification Name&method=GetClassifications&name=ClassificationName&value=ClassificationID";
string script = "window.open ('" + url + "', 'popup_window', 'width=500,height=135,left=200,top=150,scrollbars=0,resizable=no');";

You can't make the popup modal on modern browsers.你不能在现代浏览器上制作弹出模式。 (There used to be a different method you could use for popup modals, but it's deprecated now.) (曾经有一种不同的方法可以用于弹出式模态,但现在已弃用。)

By default, that window should appear in front of the window that opens it.默认情况下,该窗口应出现在打开它的窗口之前。 You can also respond to clicks on the opening window's document by calling focus on the window returned by open , to bring that other window to the foreground (stopping when you see the unload event from the popup).您还可以通过在open返回的窗口上调用focus来响应对打开窗口文档的点击,将另一个窗口带到前台(当您从弹出窗口看到unload事件时停止)。

If what you're showing in the modal doesn't have to be a separate window, you might consider not using a separate window at all, but instead using an absolutely-positioned div or similar with an element behind it that covers the entire remainder of the window so that it can prevent clicks and similar from reaching the elements underneath it.如果你的模式显示什么不必是一个单独的窗口,你可能会考虑在所有不使用一个单独的窗口,而是使用绝对定位div或类似与元素背后涵盖整个其余的窗口,以便它可以防止点击和类似的东西到达它下面的元素。 But if it has to be a separate window, you don't have much you can do other than the focus thing.但是如果它必须是一个单独的窗口,除了focus之外,你没有什么可以做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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