انسخ رمز الكود كما يلي:
<!DOCTYPE HTML>
<أتش تي أم أل>
<الرأس>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>إعلان JS عائم بملء الشاشة</title>
<نمط النوع = "نص/CSS">
div#roll{width:100px;height:100px;
</نمط>
</الرأس>
<الجسم>
<ديف>
<div><h2>إعلان JS عائم بملء الشاشة، حرك المؤشر للتوقف عن الحركة・Ke Leyi</h2></div>
</div>
<div id="roll">أنا أقوم بالإعلان<br />www.jb51.com</div>
<نوع البرنامج النصي = "نص/جافا سكريبت">
فار ggRoll = {
لفة: document.getElementById("لفة")،
السرعة: 20،
الحالةX: 1،
الحالة ص: 1،
س: 100،
ص: 300،
نظام WinW: document.documentElement.clientWidth - document.getElementById("roll").offsetWidth،
WinH: document.documentElement.clientHeight - document.getElementById("roll").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 }
}
}
فار الفاصل الزمني = setInterval("ggRoll.Go()", ggRoll.speed);
ggRoll.roll.onmouseover = function () { ClearInterval(interval) };
ggRoll.roll.onmouseout = function () { Interval = setInterval("ggRoll.Go()", ggRoll.speed) };
</script>
</الجسم>
</html>