码迷,mamicode.com
首页 > 其他好文 > 详细

飘窗代码

时间:2015-07-06 10:09:15      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>飘窗代码</title>
</head>

<body>
<div id="FlAD" style="position:absolute; z-index:10;left: 100; top: 100" > <span style="color:red; float:right; font-size:12px; cursor:pointer;" onClick="img.style.visibility = ‘hidden‘">关闭</span><br />
  <a href="#" target="_blank" title="文字"> <img src="http://210.75.213.166/Portals/0/2010images/2011lh.gif" width="160" border="0" alt="" /></a></div>
<script type="text/javascript">
<!--Begin
var img = document.getElementById(FlAD);
var xPos = 200;
var yPos = 200;
var step = 1;
var delay = 40;
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.documentElement.clientWidth || document.body.clientWidth;
height = document.documentElement.clientHeight || document.body.clientHeight;
scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
scrollTop = document.documentElement.scrollLeft || document.body.scrollTop;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + scrollLeft +px;
img.style.top = yPos + scrollTop +px;
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();
</script>
</body>
</html>

 

飘窗代码

标签:

原文地址:http://www.cnblogs.com/yjhua/p/4623548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!