朋友叫我帮找一个浮动广告层的JS特效代码,在网上找了不少都有错就随手写了一个。 点击查看效果 一、把以下代码插入<body></body>标签中: < div id ="FloatDIV" style ="position: absolute;top: 0px; border-right: activeborder 1px solid; border-top: activeborder 1px solid; border-left: activeborder 1px solid; border-bottom: activeborder 1px solid;" > 浮动层示例: < br /> < a target ="_blank" href ="tencent://message/?uin=101535223&Site=http://www.jailusd.com&Menu=yes" >< img border ="0" src ="http://wpa.qq.com/pa?p=1:101535223:3" alt ="有事您说话" ></ a > </ div > 二、把以下代码插到</body>标签之后,设置MarginLeft、MarginTop、Width、Heigth四个变量的值 < script language = " javascript " type = " text/javascript " > var MarginLeft = 30 ; // 浮动层离浏览器右侧的距离 var MarginTop = 50 ; // 浮动层离浏览器顶部的距离 var Width = 120 ; // 浮动层宽度 var Heigth = 45 ; // 浮动层高度 // 设置浮动层宽、高 function Set() { document.getElementById("FloatDIV").style.width = Width; document.getElementById("FloatDIV").style.height = Heigth;} // 实时设置浮动层的位置 function Move() { document.getElementById("FloatDIV").style.top = document.documentElement.scrollTop + MarginTop; document.getElementById("FloatDIV").style.left = document.documentElement.clientWidth - Width - MarginLeft; setTimeout("Move();",100);} Set();Move(); </ script > 转载于:https://www.cnblogs.com/jailu/archive/2006/10/24/538421.html