Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 创建新的弹出窗口时,如何使页面创建的所有弹出窗口显示在顶部?_Javascript_Html_Windows_Popup - Fatal编程技术网

Javascript 创建新的弹出窗口时,如何使页面创建的所有弹出窗口显示在顶部?

Javascript 创建新的弹出窗口时,如何使页面创建的所有弹出窗口显示在顶部?,javascript,html,windows,popup,Javascript,Html,Windows,Popup,想象一下,我们有一个全屏浏览器打开了我们的页面。所以它占据了所有的屏幕空间 我们有一些按钮可以在用户需要时打开弹出窗口,代码如下: <hr> <ul> <li><FORM><INPUT class="eButton" type="button" value="georg" onClick="window.open('./georg.flv?action=read','ge

想象一下,我们有一个全屏浏览器打开了我们的页面。所以它占据了所有的屏幕空间

我们有一些按钮可以在用户需要时打开弹出窗口,代码如下:

<hr> <ul> 
<li><FORM><INPUT class="eButton" type="button" value="georg" onClick="window.open('./georg.flv?action=read','georg','width=400,height=200,left=0,top=100,screenX=0,screenY=100')"></FORM></li> 
<li><FORM><INPUT class="eButton" type="button" value="vasia" onClick="window.open('./vasia.flv?action=read','vasia','width=400,height=200,left=400,top=100,screenX=400,screenY=100')"></FORM></li> 
</ul> <hr>  


当用户单击时,将在其单击的窗口顶部创建一个弹出窗口

但是,当他想要创建一个新的窗口时,他会点击带有按钮的全屏窗口,该窗口将弹出先前创建的窗口

但是如果我们想要这样的东西:(我在这里手动创建)

我们所有的弹出窗口都在上面。我们该怎么办?一个JS函数能帮上忙吗

带有流的窗口不应位于主页内。他们应该是独立的


这里的要点是更改主页代码,以便控制所有弹出窗口都位于顶部。

将JavaScript代码从标记中去掉(是的!)。抓住窗口的手柄,使用聚焦或模糊

<script>
openWin = function(name){
    var win = window.open('./'+name+'.flv?action=read', name, 'width=400, height=200, left=0, top=100';

win.focus() // on top
win.blur() // on bottom - this may not work, you may need to focus the current window:
window.focus();
}
</script>

<FORM><INPUT type="button" value="georg" onClick="openWin(this.value);"></FORM>

openWin=函数(名称){
var win=window.open('./'+name+'.flv?action=read',name',width=400,height=200,left=0,top=100';
win.focus()//位于顶部
win.blur()//在底部-这可能不起作用,您可能需要聚焦当前窗口:
window.focus();
}

您是否考虑过实现弹出窗口(类似于主页面上弹出窗口的div标记)而不是弹出窗口?这可能会简化您的操作。此外,关闭主窗口时,所有弹出窗口都会消失,您的脚本在默认情况下无法工作。我尝试修改它的“openWin=函数”(名称,宽度,高度,左,上){var win=window.open('./'+name+'.flv?action=read',name,'width='+width+',height='+height+',left='+top='+top+',screenX='+left+',screenY='+top);win focus();//在顶部win.blur();//在底部-这可能不起作用,您可能需要聚焦当前窗口:window.focus();}'因此对它的调用类似于'
  • '但它不起作用'=('当将
    字符串
    传递给函数时,是否需要一些
    引号