60、最简单的页面层

60、最简单的页面层

脚本说明:

把如下代码加入<body>区域中

<div id=sampleLayer style="position:absolute; top:20px; left:15px; width:100px; height:100px; background:#EEEEEE; border: 1px solid #919191; font-family:Verdana; font-size:8pt">这是个简单的层</div>

<script language=JavaScript>

var posX, posY;

var ie    = document.all?1:0;

var ns    = document.layers?1:0;

var dom   = document.getElementById?1:0;

var dhtml = new svetLayer("sampleLayer");

var path  = new Array(452,278,452,278,452,278,452,278,452,278,452,278,452,278,452,278,452,278,452,278,452,278,452,278,452,278);

var index = 0;

var trNum = 0;

function svetLayer(id)

       {

              this.name = dom?document.getElementById(id):ie?document.all[id]:ns?document.layers[id]:null;

              if (this.name !== null)

                     {

                            this.css    = (dom||ie)?this.name.style:this.name;

                            this.x      = dom?this.css.pixelLeft:ie?parseInt(this.css.left):this.css.left;

                            this.y      = dom?this.css.pixelTop:ie?parseInt(this.css.top):this.css.top;

                            this.moveTo = moveTo;

                            return this;

                     }

              else alert('Your layer does not exist');

       }

 

function moveTo(x,y)

       {

              if(dom||ie)

                     {

                            this.x=x;

                            this.y=y;

                            this.css.left=x;

                            this.css.top=y;

                     }

              else this.css.moveTo(x,y);

       }

function timeline()

       {

              if(trNum < (path.length-1))

                     {

                            dhtml.moveTo(path[trNum],path[trNum+1])

                            trNum += 2;

                            setTimeout('timeline()',10);

                     }

              else trNum=0;

       }

window.onload=timeline;

</script>

 

Write a comment

Comments: 0