一键打开多个子窗口 [英] Open multiple child windows with one click

查看:371
本文介绍了一键打开多个子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当单击一个按钮时,我试图打开多个子窗口。例如,我有一个标有1的块,当它被点击时,带有冲击波闪光视频的相应子窗口将播放。但是,我希望块2和9中的视频也可以播放,因为它们位于块1旁边。或者,如果我单击了12,则4,11,13和20的窗口也会出现,因为它们包围12,

这里是我正在使用的网站,给你一个更好的主意。



http://alexalmaguer.site90.com/



是我用来让一个视频出现子窗口的代码。

 < a href =1。 html,target =ItsAGoodDayonClick =wopen('1.html','ItsAGoodDay',400,300); return false;> 1< / a> 

1.html只是一个带有.swf的对象标签,还有一些样式将.swf保存在窗口中间。



我也使用我在本网站上找到的预制脚本来将子窗口居中放置在屏幕中间当它打开。

 <! -  
function wopen(url,name, ,w,h)
{

w + = 32;
h + = 96;
wleft =(screen.width - w)/ 2;
wtop =(screen.height - h)/ 2;

if(wleft <0){
w = screen.width;
wleft = 0;
}
if(wtop <0){
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width ='+ w +',height ='+ h +','+
'left ='+ wleft +',top ='+ wtop +','+
'location = no,menubar = no,'+
'status = no,toolbar = no,scrollbars = no,resizable = no');

win.resizeTo(w,h);

win.moveTo(wleft,wtop);
win.focus();

$ / code>

编辑:由于空间有限,我想我可能只是将窗口左侧和右侧的选定块打开,而不是顶部和底部的窗口。

解决方案



 < script>这是一个小脚本,可以帮助您: 
函数myMethod(x){
alert(Open+ x +.html);
if(x-1> 1){
alert(Open+(x-1)+.html); (x-8> 1){
alert(Open+(x-8)+.html);
}
;

if(x + 1 <= 32){
alert(Open+(x + 1)+.html);

if(x + 8 <= 32){
alert(Open+(x + 8)+.html);
}

}
< / script>

Html:

 <身体GT; 
< a href =#target =ItsAGoodDayonClick =myMethod(12)> 12< / a>
< / body>

你可以玩这个来看看你是否得到了预期的结果。
然后你可以用 wopen 函数替换这个提示符,传递html名字。



I'm trying to open multiple child windows when a single button is clicked. For instance, I have a block labelled "1" and when it is clicked, a corresponding child window with a shockwave flash video plays. However, I want the videos from block 2 and 9 to play as well, as they are next to block 1. Or, if I clicked on 12, the windows for 4, 11, 13, and 20 would appear too, since they surround 12.

Here's the website I'm working with, to give you a better idea.

http://alexalmaguer.site90.com/

This is the code I'm using to get the child window to appear for one video.

<a href="1.html," target="ItsAGoodDay" onClick="wopen('1.html', 'ItsAGoodDay', 400, 300); return false;">1</a>

1.html just has an object tag with the .swf in it, and a bit of styling to keep the .swf in the middle of the window.

I'm also using a premade script I found on this website to center the child window in the middle of the screen when it opens. I think this might need to be changed as well.

<!--
function wopen(url, name, w, h)
{

  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;

  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');

  win.resizeTo(w, h);

  win.moveTo(wleft, wtop);
  win.focus();
}

EDIT: Due to limited space, I'm thinking I might just make the windows to the left and right of the selected block open, and not the ones on top and bottom.

解决方案

Here is a small script that might help you:

<script>
     function myMethod(x){
    alert("Open " + x + ".html");
    if(x-1  > 1) {
        alert("Open " + (x-1) + ".html");
        }
    if(x-8  > 1) {
        alert("Open " + (x-8) + ".html");
    }
    if(x+1  <= 32) {
        alert("Open " + (x+1) + ".html");
        }
    if(x+8  <= 32) {
        alert("Open " + (x+8) + ".html");
    }

     }
</script>

Html:

<body>
   <a href="#" target="ItsAGoodDay" onClick="myMethod(12)">12</a>
</body>

You can play around with this to see if you are getting the desired results. Then you can replace the alert with wopen function passing the html name.

这篇关于一键打开多个子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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