求HTML网站中的漂浮窗口代码```
发布网友
发布时间:2022-05-05 10:30
我来回答
共2个回答
热心网友
时间:2022-05-17 01:50
<div id="ad" style="position:absolute">
<a href="http://xu-ni.net" target="_blank">
<img src="http://xu-ni.net/bbs/skins/copyright.gif" border="0">
</a></div>
<script>
var x = 50,y = 60
var xin = true, yin = true
var step = 1
var delay = 10
var obj=document.getElementById("ad")
function floatAD() {
var L=T=0
var R= document.body.clientWidth-obj.offsetWidth
var B = document.body.clientHeight-obj.offsetHeight
obj.style.left = x + document.body.scrollLeft
obj.style.top = y + document.body.scrollTop
x = x + step*(xin?1:-1)
if (x < L) { xin = true; x = L}
if (x > R){ xin = false; x = R}
y = y + step*(yin?1:-1)
if (y < T) { yin = true; y = T }
if (y > B) { yin = false; y = B }
}
var itl= setInterval("floatAD()", delay)
obj.onmouseover=function(){clearInterval(itl)}
obj.onmouseout=function(){itl=setInterval("floatAD()", delay)}
</script>
把上面的代码放在需要放置广告的页面HTML代码的<body></body>之间
-----上面的代码说明-------
http://xu-ni.net //换成是漂浮图片点击后出现的页面,也就是点击后出现的详细的介绍页面
http://xu-ni.net/bbs/skins/copyright.gif //换成是漂浮广告图片的URL地址,最好采用绝对路径
var x = 50,y = 60 //浮动层的初始位置,分别对应层的初始X坐标和Y坐标
var xin = true, yin = true //判断层的X坐标和Y坐标是否在在控制范围之内,xin为真是层向右移动,否则向左;yin为真是层向下移动,否则向上
var step = 1 //层移动的步长,值越大移动速度越快
var delay = 10 //层移动的时间间隔,单位为毫秒,值越小移动速度越快
热心网友
时间:2022-05-17 03:08
<div
id="img"
style="position:absolute;
left:35px;
top:556px;
width:120;
height:172">
<a
href="/"qyml7.htm">
<img
border="0"
src="/"lo1.gif"
width="140"
height="120"></a></p>
</div>
<SCRIPT
LANGUAGE="JavaScript">
<!--
Begin
var
xPos
=
20;
var
yPos
=
document.body.clientHeight;
var
step
=
1;
var
delay
=
30;
var
height
=
0;
var
Hoffset
=
0;
var
Woffset
=
0;
var
yon
=
0;
var
xon
=
0;
var
pause
=
true;
var
interval;
img.style.top
=
yPos;
function
changePos()
{
width
=
document.body.clientWidth;
height
=
document.body.clientHeight;
Hoffset
=
img.offsetHeight;
Woffset
=
img.offsetWidth;
img.style.left
=
xPos
+
document.body.scrollLeft;
img.style.top
=
yPos
+
document.body.scrollTop;
if
(yon)
{
yPos
=
yPos
+
step;
}
else
{
yPos
=
yPos
-
step;
}
if
(yPos
<
0)
{
yon
=
1;
yPos
=
0;
}
if
(yPos
>=
(height
-
Hoffset))
{
yon
=
0;
yPos
=
(height
-
Hoffset);
}
if
(xon)
{
xPos
=
xPos
+
step;
}
else
{
xPos
=
xPos
-
step;
}
if
(xPos
<
0)
{
xon
=
1;
xPos
=
0;
}
if
(xPos
>=
(width
-
Woffset))
{
xon
=
0;
xPos
=
(width
-
Woffset);
}
}
function
start()
{
img.visibility
=
"visible";
interval
=
setInterval('changePos()',
delay);
}
start();
//
End
-->
</script>