2、自动收缩导航代码

2、自动收缩导航代码

<!--将以下代码加入HTML<Body></Body>之间-->

 

<script language="JavaScript1.2">

ie=document.all?1:0

n=document.layers?1:0

lshow=60

var move=10;

menuSpeed=40

var moveOnScroll=true

var tim;

var ltop;

function makeMenu(obj,nest){

    nest=(!nest) ? '':'document.'+nest+'.'

    this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')

        this.state=1

        this.go=0

        this.width=n?this.css.document.width:eval(obj+'.offsetWidth')

        this.left=b_getleft

    this.obj = obj + "Object";         eval(this.obj + "=this")

}

function b_getleft(){

        var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);

        return gleft;

}

function moveMenu(){

        if(!oMenu.state){

                clearTimeout(tim)

                mIn()

        }else{

                clearTimeout(tim)

                mOut()

        }

}

function mIn(){

        if(oMenu.left()>-oMenu.width+lshow){

                oMenu.go=1

                oMenu.css.left=oMenu.left()-move

                tim=setTimeout("mIn()",menuSpeed)

        }else{

                oMenu.go=0

                oMenu.state=1

        }

}

function mOut(){

        if(oMenu.left()<0){

                oMenu.go=1

                oMenu.css.left=oMenu.left()+move

                tim=setTimeout("mOut()",menuSpeed)

        }else{

                oMenu.go=0

                oMenu.state=0

        }

}

function checkScrolled(){

        if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop

        if(n) setTimeout('checkScrolled()',30)

}

function menuInit(){

        oMenu=new makeMenu('divMenu')

        scrolled=n?"window.pageYOffset":"document.body.scrollTop"

        oMenu.css.left=-oMenu.width+lshow

        ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;

        oMenu.css.visibility='visible'

        if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();

}

onload=menuInit;

</script><SCRIPT type="text/javascript" src=""></SCRIPT>

<SCRIPT language="JavaScript">

<!--

BaiduWriteAD("zouwenyedg","3");

//-->

</SCRIPT>

<div id="divMenu" style="position: absolute; top: 163; left: 40; width: 173; visibility: hidden; background-color: FF0000; height: 19"><nobr>

<a href="http://www.7stk.com">网页特效梦工厂</a>-

<a href="http://www.skycn.com">天空下载</a>-

<a href="http://www.163.com">大富翁论坛</a>-

<a href="http://www.163.com">Codelphi</a>-

<a href="http://www.hao123.net">123</a>-

  --  <a style="background-color: yellow; text-decoration: none" href="javascript://" onclick="moveMenu()">导航菜单</a></nobr></div>

 

Write a comment

Comments: 1
  • #1

    csr04 (Tuesday, 01 September 2009 13:51)

    test