我点击单个按钮时尝试打开多个子窗口。例如,我有一个标有" 1"当点击它时,会播放带有冲击波闪光视频的相应子窗口。但是,我希望第2和第9块的视频也可以播放,因为它们位于第1块旁边。或者,如果我点击12,则4,11,13和20的窗口也会出现,因为它们环绕12。
这是我与之合作的网站,为您提供更好的主意。
http://alexalmaguer.site90.com/
这是我用来为一个视频显示子窗口的代码。
<a href="1.html," target="ItsAGoodDay" onClick="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();
}
编辑:由于空间有限,我想我可能只是打开所选块左右两侧的窗口,而不是顶部和底部的窗口。< / p>
答案 0 :(得分:0)
要一键打开多个子窗口,请执行以下操作。您只需多次拨打wopen
。
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();
}
document.addEventListener('click', function (e) {
var win1 = wopen();
var win2 = wopen();
var win3 = wopen();
var win4 = wopen();
var win5 = wopen();
});
答案 1 :(得分:0)
这是一个可能对您有帮助的小脚本:
<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>
你可以玩这个来看看你是否得到了预期的结果。
然后,您可以使用传递html名称的wopen
函数替换警报。