let baseUrl = 'index.html'
let message = {
method: 'sendSign',
url: url,
value: ''
}
const bodyH = document.querySelector('body').offsetHeight
var win = window.open(
baseUrl,
JSON.stringify(message),
`width=400,height=80,left=0,top=${bodyH},scrollbars=yes`
);
if (win == null) {
alert(
"您的浏览器启用弹出窗口过滤功能!\n\n请暂时先关闭此功能!"
);
}
setTimeout(() => {
console.log(win.window)
win.window.opener = null;
win.window.close();
}, 1000)
const loop = setInterval(() => { // 使用定时器查询当前状态
if (win && win.closed) { // 进行判断条件 closed属性就是返回当前窗口的状态
console.log('我被关闭了')
clearInterval(loop); // 清除定时器
// Logical code
}
}, 500);
JS window.open 监听tab页的关闭
最新推荐文章于 2025-03-12 11:08:24 发布