如何将打开的popUps放入数组,并在每次创建新数组时将它们全部放在顶部? [英] How to put opened popUps into array and make them all on top each time new one is created?

查看:95
本文介绍了如何将打开的popUps放入数组,并在每次创建新数组时将它们全部放在顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以打开popUps我使用

 < script> 
openWin = function(name,width,height,left,top){
left = left + 1;
top = top + 1;
var file ='。/'+ name +'。flv?action = read';
var settings ='width ='+ width +',height ='+ height +',left ='+ left +',top ='+ top +',screenX ='+ left +',screenY ='+ top +'' ;
// alert(file);
//警报(设置);
var win = window.open(文件,名称,设置);
}
< / script>

我想知道如何在打开新的popUps时将popUps放入数组中,并且每次将所有创建的popUps放在顶部新创建一个?

解决方案

只需创建一个空数组来存储每个窗口。在数组中创建一个新的循环并调用每个窗口的 focus 方法后:

  var openWin =(function()
{
var popups = [];
返回函数(名称,宽度,高度,左,顶部)
{
++ left;
++ top;
var file ='./'+ name +'.flv?action = read';
var settings ='width ='+ width + ',height ='+ height +',left ='+ left +',top ='+ top +',screenX ='+ left +',screenY ='+ top;
popups.push(window。打开(文件,名称,设置));
for(var i = 0; i< popups.length; ++ i)
popups [i] .focus();
}
})();

您可能希望将所有内容放在闭包中,因此数组不会被公开。 p>

So to open popUps I use

<script>
openWin = function(name, width, height, left, top){
    left=left+1;
    top=top+1;
    var file='./'+name+'.flv?action=read';
    var settings='width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'';
    //alert(file);
    //alert(settings);
    var win = window.open(file, name, settings);
}
      </script>

I wonder how to put popUps into array when opening new one and make all created popUps on top each time new one is created?

解决方案

Just create an empty array to store each window. After creating a new one loop through the array and call each window's focus method:

var openWin = (function ()
{
    var popups = [];
    return function (name, width, height, left, top)
    {
        ++left;
        ++top;
        var file = './' + name + '.flv?action=read';
        var settings = 'width=' + width  + ',height=' + height + ',left=' + left + ',top=' + top + ',screenX=' + left + ',screenY=' + top;
        popups.push(window.open(file, name, settings));
        for (var i = 0; i < popups.length; ++i)
            popups[i].focus();
    }
})();

You may want to put everything inside a closure, so the array won't be exposed.

这篇关于如何将打开的popUps放入数组,并在每次创建新数组时将它们全部放在顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆