感谢您花时间看我的问题。
我有两个不同的 window.open 请求,具体取决于用户是单击移动按钮还是网络摄像头按钮。
单击移动按钮时, mobcamWindow将以一定(小)尺寸打开
单击网络摄像头按钮时,网络摄像头窗口将以不同(大)尺寸打开
这些窗口将以正确的大小打开,但是如果在(较小的)mobcamWindow打开时单击网络摄像头按钮,我希望关闭当前的mobcamWindow并打开新的(较大的)网络摄像头窗口(以正确的大小)和反之亦然。
目前,窗口不会关闭,但 URL 将分别更改为正确的mobcamWindow和webcamWindow,但窗口将保持相同的大小。
我试过做 window.resize 没有用,window.close 也不起作用。
我的代码如下。(我有两个函数来处理每个mobcamWindow和webcamWindow,每个函数都有一个 IF 语句来检查mobcamWindow或webcamWindow是否打开,如果是则关闭它。
var webcamWindow = null; // global variable
var mobcamWindow = null; // global variable
function openStreamPopupWebcam(elem) {
if(webcamWindow == null || webcamWindow.closed)
/* if the pointer to the window object in memory does not exist
or if such pointer exists but the window was closed */
{
if(mobcamWindow){
mobcamWindow.close();
}
/*if mobile window is open, close mobile window*/
webcamWindow = window.open(elem.href, "window", "width=470,height=320,resizable,status").focus();
/* then create it. The new window will be created and
will be brought on top of any other window. */
}
}
function openStreamPopupMobile(elem) {
if(mobcamWindow == null || mobcamWindow.closed)
/* if the pointer to the window object in memory does not exist
or if such pointer exists but the window was closed */
{
if(webcamWindow){
webcamWindow.close();
}
/*if mobile window is open, close mobile window*/
mobcamWindow = window.open(elem.href, "window", "width=445,height=666,resizable,status").focus();
/* then create it. The new window will be created and
will be brought on top of any other window. */
}
}
如果您需要更多信息或发现难以理解我,请询问,我会尽力解释。
谢谢你。