阻止弹出窗口打开两次

发布于 2024-10-08 13:57:58 字数 612 浏览 0 评论 0原文

您好,我的问题如下:我在页面加载时使用音乐播放器打开了一个弹出窗口。 问题是每次加载页面时都会打开弹出窗口。此外,用户应该能够选择是否希望在下次访问该页面时打开音乐播放器。 (在主页上)

<html>
<head>
<title>
testpage music player
</title>
<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=250,top=690,left=390');");
}
</script>
</head>
<BODY onLoad="javascript:popUp('http://www.ccc-clan.com/board/popupex.html')">
</body>
</html>

Hi my problem is as follows: I have a popup window opening on pageload with a music player.
The problem is that the popup window opens every time i load the page. Also users are supposed to be able to choose if they want the music player to open the next time they visit the page. (Its on the homepage)

<html>
<head>
<title>
testpage music player
</title>
<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=250,top=690,left=390');");
}
</script>
</head>
<BODY onLoad="javascript:popUp('http://www.ccc-clan.com/board/popupex.html')">
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

〆一缕阳光ご 2024-10-15 13:57:58

在打开之前给您的窗口命名

,检查是否存在具有名称的元素...

http://tech.chitgoks.com/2009/09/11/javascript-check-if-popup-window-exists-using-its-窗口名称/

give your window a name

before the open, check for existence of the element with name...

http://tech.chitgoks.com/2009/09/11/javascript-check-if-popup-window-exists-using-its-window-name/

俏︾媚 2024-10-15 13:57:58

eval = BAD

window["page" + id] = window.open(...)

问题是这些变量被破坏并且毫无用处。唯一的方法是设置一个窗口打开的会话 cookie。当弹出窗口关闭时,销毁 cookie。

但为什么是音乐呢?所以20世纪90年代

eval = BAD

window["page" + id] = window.open(...)

Problem is these variables get destroyed and it is useless. Only way would be to set a session cookie that the window is open. When the pop up is closed, destroy the cookie.

But why music? So 1990's

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