[英]Auto-loading page on start up into pop-up window when pop-up window is active
Hard to come up with a title, my apologizes. 抱歉,想出一个标题。
Problem is this: Since modern web-browsers disable pop-up windows I am in need of a work-around. 问题是这样的:由于现代的网络浏览器会禁用弹出窗口,因此我需要一种解决方法。
When a visitor comes to the website they are prompt to press a button. 访客进入网站时,会提示他们按下一个按钮。 Once the button is pressed a pop-up window is launched with the following code:
按下按钮后,将弹出一个带有以下代码的窗口:
w = window.open('/audio/audioplayer.php?id='+audioId, 'audioplayer', params);
Now that the pop-up is open I would like when the visitor views other pages the pop-up is loaded with specific information based on whatever page they are on. 既然弹出窗口是打开的,我希望当访问者查看其他页面时,弹出窗口会根据他们所在的页面加载特定信息。
I am not sure if this is possible or how I can do this (check if the pop-up window is open, and if it is load the information, and if its not re-display the button) 我不确定这是否可行或我该怎么做(检查弹出窗口是否打开,是否正在加载信息,以及是否未重新显示按钮)
I don't think it is possible to detect where the popup is open of not. 我认为不可能检测到弹出窗口未打开的位置。
Have you thought about using a dialog? 您是否考虑过使用对话框? Rather than a popup?
而不是弹出窗口?
window.open
returns a windowObjectReference - this is the only way you can talk to the popup window. window.open
返回windowObjectReference-这是您可以与弹出窗口对话的唯一方法。 In particular, you can tell if that window is closed with the windowObjectReference.closed
attribute. 特别是,您可以使用
windowObjectReference.closed
属性判断该窗口是否关闭。 And the popup window has a window.opener
attribute that references the parent window back. 弹出窗口具有一个
window.opener
属性,该属性引用了父窗口。 You can use both to communicate. 您可以使用两者进行交流。
However, it seems you want to keep this communication between page loads. 但是,您似乎希望在页面加载之间保持这种通信。 You have a few options:
您有几种选择:
window.opener
. window.opener
对其进行设置。 This link shows this approach and also another one with frames. position: fixed
could get you a similar result, and might save you from that method of communication between windows, however it also leads to having one dialog per page, so you need to ask the server if another instance of the dialog is running. position: fixed
div可能会给您带来类似的结果,并且可能使您免于使用Windows之间的这种通信方法,但是它还会导致每页显示一个对话框,因此您需要询问服务器是否该对话框的另一个实例是运行。 Not quite sure if other methods of sync are viable for this (localstorage?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.