码迷,mamicode.com
首页 > Web开发 > 详细

js鼠标滑轮侧边广告(仅IE可用)

时间:2015-03-17 21:40:48      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>鼠标滑轮侧边广告</title>
</head>

<body>
<div style="width:993;height:1799;text-align:center">
<img src="images/contentpic.jpg"/>
</div>

<div style="top:30px;left:50px;position:absolute;z-index:5; " id="div">
<img src="images/advpic.jpg" />
<img src="images/close.jpg" onclick="showclose()" style="margin:0px -15px;position:absolute"/>
</div>

</body>

<script type="text/javascript">

//获取当前ID
var divobj = document.getElementById("div");

//获取长宽
var objtop = parseInt(divobj.style.top);
var objleft = parseInt(divobj.style.left);


//鼠标滚动事件
function move(){

var imgtop = document.documentElement.scrollTop;
var imgleft = document.documentElement.scrollLeft;

divobj.style.top = parseInt(objtop+imgtop)+"px";
divobj.style.left = parseInt(objleft+imgleft)+"px";

}

onscroll = move;

//关闭广告
function showclose(){
document.getElementById("div").style.display="none";
}
</script>
</html>

 

 

技术分享技术分享

js鼠标滑轮侧边广告(仅IE可用)

标签:

原文地址:http://www.cnblogs.com/zengweiB208/p/4345426.html

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