只打开一个子窗口
<
script type
=
"
text/javascript
"
>
var
WindowObjectReference
=
null
;
//
global variable 打开窗口的对象
function
openWin(url)
...
{
if(WindowObjectReference == null || WindowObjectReference.closed)
...{
WindowObjectReference = window.open(url);
/**//*
参数可以用 "resizable=yes,scrollbars=yes,status=yes"
*/
}
else
...{
alert("已经打开了");
WindowObjectReference.focus();
};
// WindowObjectReference.document.write("asdf");
}
</
script
>
<script language=javascript>
function openwin(url,myid)
{
document.winopen.id.value=myid;
document.winopen.action=url;
document.winopen.submit();
}
</script>
<form id=winopen name=winopen target=_blank><input type=hidden name="id"></form>
<input type="button" id="btnSure" name="btnSure" value="提交" onclick=" openwin('http://asdf','123') " >
<tr onmouseover=" openwin('http://asdf','123') " >
本文介绍了一种使用 JavaScript 实现的仅允许同时打开一个子窗口的方法。通过全局变量 WindowObjectReference 跟踪窗口状态,确保同一时间内只有一个子窗口处于活动状态。如果尝试再次打开窗口,则会聚焦已存在的窗口。
621

被折叠的 条评论
为什么被折叠?



