与元引用相同的弹出窗口
我想在页面加载时打开页面 [pop up],并且我的页面有元引用标记,
<meta http-equiv="refresh" content="300">
我必须每 5 分钟弹出一次窗口。我正在使用下面的代码,
<script type="text/javascript">
window.open("http://google.com");
</script>
它工作正常,但每 5 分钟就会给我一个新的 IE 窗口。我希望如果该 URL 已经打开,它只会引用浏览器。
我简单地说,我希望每 5 分钟刷新一次弹出窗口,而不是每次都打开新窗口。
有什么帮助吗?
我对 Javascript、JQuery 或服务器端编码的解决方案非常满意。
I want to open page [pop up] on page load and my page has meta referesh tag
<meta http-equiv="refresh" content="300">
I have to pop up the window every 5 minutes. I am using the below code
<script type="text/javascript">
window.open("http://google.com");
</script>
It is working fine but it is giving me the new IE window in every 5 minute. I want that if that URL is already opened it will just referesh the browser.
I brief, in every 5 minutes I want pop window should be refreshed rather than open new window each and every time.
Any help?
I am perfectly fine with the solution either in Javascript, JQuery or server side coding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 window.open 方法中传递一个名称,如下所示:
然后,弹出窗口将在同一个弹出窗口中打开 - 刷新弹出窗口中的页面。
如果尚未打开弹出窗口,则会打开一个。
顺便说一句,每 5 分钟刷新一次打开弹出窗口的页面来刷新/打开弹出窗口可能不是最有效的解决方案(取决于其他情况)。
您可能想考虑使用超时函数来启动 window.open。请参阅 setInterval 方法。
Pass along a name in your window.open method, like this:
The popup will then be opened in the same popup - refreshing the page in the popup.
If no popup window is open yet, one will be opened.
As a side note, refreshing the page that is opening the popup every 5 minutes to refresh/open the popup window is probably not the most efficient solution (depending on what else is happening).
You may want to look into using a timeout function the launch the window.open instead. See setInterval method.
在页面加载时设置 cookie 并在执行
window.open("http://google.com");
之前检查 cookie 是否存在,这将帮助您仅打开弹出窗口一次。
set a cookie on page load and check if the cookie exist before executing
window.open("http://google.com");
This will help you open the popup only once.