คัดลอกรหัสรหัสดังนี้:
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">>
<title> รหัสโฆษณาบนเว็บลอยด้วยปุ่มปิด </title>
</head>
<body>
<div id = "img" style = "ตำแหน่ง: สัมบูรณ์; ซ้าย: 311; top: 815; การมองเห็น: ซ่อน; erval = setInterval ('changepos (), ล่าช้า)" allign = "ขวา">
<a href = "#" target = "_lank"> <img src = "เส้นทางรูปภาพ" ออนไลน์ "ออนไลน์ =" return imgzoom (นี่, 600); style = "เคอร์เซอร์: ตัวชี้;"/> </a>
<span style = "เคอร์เซอร์: Hand; สี: สีแดง; Font-Weight: BOLD" onClick = "ClearInterval (Interval); img.style.visibility = 'Hidden'"> x </span>
</div>
<ภาษาสคริปต์ = JavaScript src = ff.js>
</script>
</body>
</html>
รหัส ff.js
คัดลอกรหัสรหัสดังนี้:
var xpos = 20;
var ypos = document.body.clitingHeight;
var step = 1;
var delay = 30;
ความสูง var = 0;
var hoffset = 0;
var war woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
ช่วงเวลา var;
img.style.top = ypos;
ฟังก์ชั่น ChangePos () {{)
width = document.body.clientwidth;
ความสูง = document.body.clitingHeight;
hoffset = img.offSetheight;
woffset = img.offsetWidth;
img.style.left = xpos + dcument.body.scrollleft;
img.style.top = ypos + dcument.body.scrolltop;
ถ้า (yon) {
ypos = ypos + step;
-
อื่น {
ypos = ypos -step;
-
ถ้า (ypos <0) {
YON = 1;
ypos = 0;
-
if (ypos> = (ความสูง -Host) {{
yon = 0;
ypos = (ความสูง -hoffset);
-
ถ้า (xon) {
XPOS = XPOS + ขั้นตอน;
-
อื่น {
xpos = xpos -step;
-
ถ้า (xpos <0) {
Xon = 1;
xpos = 0;
-
if (xpos> = (width -woffset) {{
Xon = 0;
xpos = (ความกว้าง -woffset);
-
-
ฟังก์ชั่นเริ่มต้น () {
img.style.visibility = "มองเห็นได้";
Interval = setInterval ('changepos (), ล่าช้า);
-
เริ่ม ();