新开窗口
// 调用 openNewWin(url)
<script type="text/javascript">
var newWinObj = null;
function openNewWin(url)
{
if(window.opener&&window.opener==newWinObj)
{
window.opener.location=url;
}
//以下代码实现 只打开一个窗口
else if(newWinObj == null || newWinObj.closed)
{
newWinObj = window.open(url);
}
else
{
newWinObj.location=url;
}
}
</script>
// 调用 openNewWin(url)
<script type="text/javascript">
var newWinObj = null;
function openNewWin(url)
{
if(window.opener&&window.opener==newWinObj)
{
window.opener.location=url;
}
//以下代码实现 只打开一个窗口
else if(newWinObj == null || newWinObj.closed)
{
newWinObj = window.open(url);
}
else
{
newWinObj.location=url;
}
}
</script>
本文介绍了一种使用JavaScript实现的单窗口管理方法,通过检测现有窗口的状态来控制新窗口的打开或更新,有效避免了多个相同页面的同时存在,提高了用户体验。
1万+

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



