
當我們看到界面中到處都是不健康的廣告和假廣告時心情是非常復雜的,很想將它一舉消滅掉因為這些廣告不僅不美觀很難看而且最重要的事它里面插入了許多另外的網頁和木馬病毒等等,所以小編我為了大家解決這些問題而編輯了本篇文章。
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>js全屏漂浮廣告_www.jquerycn.cn</title>
<style type="text/css">
div#roll{width:100px;height:100px; background-color:#000; color:#fff; position:absolute;}
</style>
</head>
<body>
<div>
<div><h2>js全屏漂浮廣告,移入光標停止移動</h2></div>
</div>
<div id="roll">我是廣告<br />www.jquerycn.cn</div>
<script type="text/javascript">
var ggroll = {
roll: document.getelementbyid("roll"),
speed: 20,
statusx: 1,
statusy: 1,
x: 100,
y: 300,
winw: document.documentelement.clientwidth - document.getelementbyid("roll").offsetwidth,
winh: document.documentelement.clientheight - document.getelementbyid("roll").offsetheight,
go: function () {
this.roll.style.left = this.x + 'px';
this.roll.style.top = this.y + 'px';
this.x = this.x + (this.statusx ? -1 : 1)
if (this.x < 0) { this.statusx = 0 }
if (this.x > this.winw) { this.statusx = 1 }
this.y = this.y + (this.statusy ? -1 : 1)
if (this.y < 0) { this.statusy = 0 }
if (this.y > this.winh) { this.statusy = 1 }
}
}
var interval = setinterval("ggroll.go()", ggroll.speed);
ggroll.roll.onmouseover = function () { clearinterval(interval) };
ggroll.roll.onmouseout = function () { interval = setinterval("ggroll.go()", ggroll.speed) };
</script>
</body>
</html>
如果 你會利用JS
特效代碼的話就請一定要嘗試一下我們文章中所包含的代碼,它可以讓你在打開滿是移動的窗口廣告和復雜而混亂的界面時,只要你使用這個代碼就可以立即體驗到它瞬間可以停止的效果。