JavaScript -- 广告随鼠标移动, 点击一次后关闭

<!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=gb2312" />
<title>无标题文档</title>

<style type="text/css">
#bodyId{
	border:#0000FF solid 1px; 
	width:500px;
	height:800px;
}

</style>

<script type="text/javascript">
window.onload = function()
{
	document.body.onmouseover = function()
	{
		var adId = document.getElementById("adId");
		adId.style.left = event.x - 10;
		adId.style.top = event.y - 10;
		
	}
}

function closed()
{
	var adId = document.getElementById("adId");
	adId.style.display = "none";
}

</script>

</head>

<body>

<div id="adId" style="position:absolute; left:0; top:0;" onclick="closed()">
	<a href="http://www.baidu.com" target="_blank" ><img src="1.jpg" width="80px" height="100px" /> </a>
</div>

<div id="bodyId" >
	body 区域
</div>

</body>
</html>


posted @ 2013-12-01 18:31  今晚打酱油_  阅读(195)  评论(0编辑  收藏  举报