有没有办法检测是否打开了同一应用程序的多个浏览器选项卡。
假设我有 www.test.com 并且我打开了该网站的 4 个选项卡。
有没有办法检测在 JavaScript 中打开多个选项卡?
最佳答案
您可以使用我的 sysend.js library ,它使用 localStorage 在打开的选项卡/窗口之间发送消息。所有要做的就是这段代码:
sysend.on('notification', function() {
sysend.broadcast('multiple');
});
sysend.on('multiple', function() {
// this will fire n-1 times if there are n tabs open if n > 1
alert('multiple pages');
});
sysend.broadcast('notification');
关于javascript - 检测在 javascript 中打开的同一个应用程序的多个 chrome 选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35751096/