网页之间窗口切换方法二

//- - - - - - - - - - - - - - - - - - - - start.htm - -=
<a href="a.htm" target='openA'>start</a>
//- - - end start.htm

//- - - - - - - - - - - - - - - - - - - - -  fun.js - -=
var winFocused = false;
var cWinNameA = "A";
var cWinNameB = "B";
var cWinNameC = "C";


function openWin( strWinName )
{
    setCookie(strWinName);
    winFocused = false;//show 了别人后自己当然失去焦点啦。
    MinimizeThis.Click();
}

function getFocus( oForm )
{
    oForm.focus();
    winFocused = true;//show 了自己后自己当然获得焦点啦。
}

function setCookie(sVal)
{
    document.cookie = "focusedWin='"+escape(sVal)+"'";
}

function getCookie()
{
    return unescape(document.cookie).charAt(document.cookie.search(/focusedWin/i)+12);//写的不规范;
}

function checkWin( winName )
{
    var strThisName = winName;

    setTimeout( "checkWin('"+strThisName+"')", 100);

    if(!winFocused)
if( getCookie() == thisWinName )
    getFocus(self);

}
//- - - end fun.js

//- - - - - - - - - - - - - - - - - - - - - - a.htm - -=
<script language="JavaScript" src="fun.js"></script>
<script language='javascript'>
var thisWinName = cWinNameA;
setCookie(thisWinName);
checkWin(thisWinName);
document.write( document.cookie );
</script>
-----------------------------------a.htm
<object id=MinimizeThis classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
    <param name="Command" value="Minimize">
</object>
<div>a.htm</div>
<a href='b.htm' target='openB' onClick="openWin( cWinNameB );">openB</a>
<BR>
<a href='c.htm' target='openC' onClick="openWin( cWinNameC );">openC</a>
//- - - end a.htm

//- - - - - - - - - - - - - - - - - - - - - - b.htm - -=
<script language="JavaScript" src="fun.js"></script>
<script language='javascript'>
var thisWinName = cWinNameB;
checkWin(thisWinName);
document.write( document.cookie.charAt(document.cookie.search(/focusedWin/i)+12) );
</script>

-----------------------------------b.htm
<object id=MinimizeThis classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
    <param name="Command" value="Minimize">
</object>
<div>b.htm</div>
<a href='c.htm' target='openC' onClick="openWin( cWinNameC );">openC</a>|<a href="a.htm" target='openA' onClick="openWin( cWinNameA )">back</a>
//- - - end b.htm

//- - - - - - - - - - - - - - - - - - - - - - c.htm - -=
<script language="JavaScript" src="fun.js"></script>
<script language='javascript'>
var thisWinName = cWinNameC;
checkWin(thisWinName);
document.write( document.cookie.charAt(document.cookie.search(/focusedWin/i)+12) );
</script>

-----------------------------------c.htm
<object id=MinimizeThis classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
    <param name="Command" value="Minimize">
</object>
<div>c.htm</div>
<a href='b.htm' target='openB' onClick="openWin( cWinNameB );">openB</a>|<a href="a.htm" target='openA' onClick="openWin( cWinNameA )">back</a>
//- - - end c.htm

阅读更多
个人分类: Script
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭