บทความนี้อธิบายถึงวิธีการของ JS เพื่อให้ได้ภาพหายไปที่ จำกัด เวลา แบ่งปันสำหรับการอ้างอิงของคุณ วิธีการใช้งานเฉพาะมีดังนี้:
คัดลอกรหัสดังนี้: <html>
<title> รูปภาพที่หายไปภายในเวลาที่กำหนด </title>
<body>
<ภาษาสคริปต์ = JavaScript>
<!-ซ่อนสคริปต์จากเบราว์เซอร์เก่า-
// 1) สร้างโลโก้ 88*31
if (document.images)
var staticlogo = ภาพใหม่ (758,100)
// 2) ตั้งค่าเส้นทางไปยังโลโก้
staticlogo.src = "/images/banner.gif"
// 3) ต่อไปนี้คือการเชื่อมต่อที่แสดงโดยโลโก้
var logolink = "http://www.vevb.com/"
// 4) ตั้งค่าแอตทริบิวต์ alt
varttext = "รหัสบ้าน"
// 5) ตั้งค่าแอตทริบิวต์ต่อไปนี้เป็น 1 หรือ 0 (1 ไม่ซ้ำกับ IE ทำให้โลโก้ปรากฏขึ้น)
var fadeintoview = 1
/* 6) ในที่สุดก็ตั้งค่าเวลาสำหรับการแสดงโลโก้เช่น 12 วินาทีและค่า 0 หมายความว่าการแสดงผลจะปรากฏขึ้นเสมอ
-
var visibleduration = 5
ฟังก์ชั่น regenerate () {
window.location.reload ()
-
ฟังก์ชั่น regenerate2 () {
if (document.layers)
settimeout ("window.onresize = regenerate", 400)
-
var fadeset = ''
if (fadeintoview)
fadeset = "ตัวกรอง: alpha (opacity = 0)"
if (document.all)
document.write ('<span id = "โลโก้" "style ="'+fadeset+'; ตำแหน่ง: Absolute; Top: 100; Width:'+Staticlogo.width+'; ความสูง:'+Staticlogo.height+'"> </span>')
ฟังก์ชั่น bringintoview () {
if (logo.filters.alpha.Opacity <= 95)
Logo.filters.alpha.Opacity+= 5
อื่น{
ClearInterval (ดู)
if (visibleduration! = 0)
Settimeout ("Logo.style.visibility = 'Hidden'", Visibleduration*1000)
-
-
ฟังก์ชั่น createLogo () {
StaticImage = เลเยอร์ใหม่ (100)
staticimage.left = -300
staticimage.top = 120
staticimage.document.write ('<a href = "'+logolink+'"> <img src = "'+staticlogo.src+'" border = 0> </a>')
staticimage.document.close ()
StaticImage.visibility = "แสดง"
regenerate2 ()
staticitns ()
-
if (document.layers)
window.onload = createLogo;
if (document.all) {
W = 2
h = 2
Logo.style.left = W
Logo.style.top = H
-
ฟังก์ชั่นโลโก้ () {
var w2 = document.body.scrollleft+w
var h2 = document.body.scrolltop+h
Logo.style.left = W2
Logo.style.top = H2
-
ฟังก์ชั่น logoit2 () {
staticimage.left = pagexoffset+2
staticimage.top = pageyoffset+2
-
ฟังก์ชัน insertimage () {
Logo.innerhtml = '<a href = "'+logolink+'"> <img src = "'+staticlogo.src+'" border = 0> </a>'
if (fadeintoview)
ViewIt = setInterval ("bringintoview ()", 100)
อื่น{
if (visibleduration! = 0)
Settimeout ("Logo.style.visibility = 'Hidden'", Visibleduration*1000)
-
-
if (document.all) {
window.onscroll = logoit
window.onresize = ฟังก์ชั่นใหม่ ("window.location.reload ()")
window.onload = insertimage
-
ฟังก์ชั่น staticitns () {
setInterval ("logoit2 ()", 90)
if (visibleduration! = 0)
Settimeout ("StaticImage.visibility = 'ซ่อน'", visibleduration*1000)
-
-
</script>
</body>
</html>
<br>
<br>
<br>
<br>
<br>
<br> ภาพจะหายไปโดยอัตโนมัติหลังจาก 5 วินาที
<br>
<br>
<br>
ฉันหวังว่าบทความนี้จะเป็นประโยชน์กับการเขียนโปรแกรม JavaScript ของทุกคน