javascript - 在父选项卡(页面)上显示叠加层,直到打开其所有子选项卡(页面)

标签 javascript c# jquery html asp.net-mvc

假设我有父页面。

Click

当我单击“打印”时,会打开一个新选项卡(页面)以进行打印预览。

我想要的是,当我单击“打印”时,父选项卡(页面)上应显示覆盖层,以停止进一步的工作,直到子选项卡关闭。

Because when print tab (page) (child) is opened, most of the functions on parent tab (page) are not working properly.

注意:我正在使用 Google 默认打印/预览功能。

我无法编写代码来执行上述场景。如何在父页面中检测到其子页面已关闭?

最佳答案

您可以在 jQuery 中使用dialog follow this link to view或者您可以在代码中使用,例如

var childNode= window.open('/uri of child');

然后使用

childNode.onunload = function(){  
// code after child closed
}

如果没有的话你也可以尝试

window.onunload = function() {if(!window.opener.closed && childNode.closed){
//code after child closed
}}

关于javascript - 在父选项卡(页面)上显示叠加层,直到打开其所有子选项卡(页面),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32986801/

相关文章:

jquery - 使用jquery替换脚本src未执行

javascript - 使用变量 "name"不适用于 JS 对象

javascript - 通过 onKeyPress 或 onKeyDown 在 React 中仅允许数字

javascript - 如何在滚动条上移动 div?

c# - WPF Visual Studio 调试 - 控制台

php - 通过ajax向 Controller 发送参数

javascript - 在 Javascript 对象的一个​​属性中添加对它的引用是一种不好的做法吗?

C# ref 关键字用法

c# - ASP.NET Core - 处理 404 和 500 错误

javascript - jquery/ajax - .load 保持相同的 JQuery