คัดลอกรหัสรหัสดังต่อไปนี้:
<!DOCTYPE HTML>
<html>
<หัว>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>โฆษณาลอยแบบเต็มหน้าจอ JS</title>
<style type="text/css">
div#roll{width:100px;height:100px; พื้นหลังสี:#000; สี:#fff;
</สไตล์>
</หัว>
<ร่างกาย>
<div>
<div><h2>โฆษณาลอยแบบเต็มหน้าจอ JS เลื่อนเคอร์เซอร์เพื่อหยุดการเคลื่อนที่・Ke Leyi</h2></div>
</div>
<div id="roll">ฉันกำลังโฆษณา<br />www.jb51.com</div>
<script type="text/javascript">
var ggRoll = {
ม้วน: document.getElementById("ม้วน"),
ความเร็ว: 20,
สถานะX: 1,
สถานะ Y: 1,
x: 100,
ใช่: 300,
winW: document.documentElement.clientWidth - document.getElementById("ม้วน").offsetWidth,
winH: document.documentElement.clientHeight - document.getElementById("ม้วน").offsetHeight,
ไป: ฟังก์ชั่น () {
this.roll.style.left = this.x + 'px';
this.roll.style.top = this.y + 'px';
this.x = this.x + (this.statusX ? -1 : 1)
ถ้า (this.x < 0) { this.statusX = 0 }
ถ้า (this.x > this.winW) { this.statusX = 1 }
this.y = this.y + (this.statusY ? -1 : 1)
ถ้า (this.y < 0) { this.statusY = 0 }
ถ้า (this.y > this.winH) { this.statusY = 1 }
-
-
var ช่วง = setInterval("ggRoll.Go()", ggRoll.speed);
ggRoll.roll.onmouseover = ฟังก์ชั่น () { clearInterval (ช่วงเวลา) };
ggRoll.roll.onmouseout = function () { ช่วง = setInterval("ggRoll.Go()", ggRoll.speed) };
</สคริปต์>
</ร่างกาย>
</html>