Artikel ini menjelaskan tampilan acak efek gambar ketika JS mengimplementasikan pemuatan halaman. Bagikan untuk referensi Anda, sebagai berikut:
<html> <head> <title> JS Efek gambar acak </title> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"> <style type = "text/css"> <!-img {perbatasan: #99999; gaya perbatasan: bertitik; Border-top-width: 1px; Batas-lebar-lebar: 1px; Border-Bottom-Width: 1px; Border-left-width: 1px}-> </style> </ head> <bahasa skrip = "javascript"> var rand1 = 0; var userand = 0; gambar = array baru; gambar [1] = gambar baru (); gambar [1] .src = "img/a1.jpg"; gambar [2] = gambar baru (); gambar (); new Image();images[3].src = "img/a3.jpg";images[4] = new Image();images[4].src = "img/a4.jpg";function swapPic() {var imgnum = images.length - 1;do {var randnum = Math.random();rand1 = Math.round((imgnum - 1) * randnum) + 1;} while (rand1 == userand); userand = rand1; document.randimg.src = gambar [userand] .src;} </script> <body bgcolor = "#ffffff" text = "#000000" Onload = "swappic ()"> <iMg name = "randimg" src = "iMg/iMg/a1.p" ipg/a1.jg/a1.Kode diuji dan dijalankan secara normal. Saya tidak akan lagi memiliki rendering berjalan di sini. Teman yang tertarik dapat memilih beberapa foto wanita cantik untuk menguji mereka untuk melihat efeknya.
For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript Traversal Algorithm and Skills", "Summary of JavaScript Switching Special Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures dan keterampilan algoritma "dan" Ringkasan Penggunaan Operasi Matematika JavaScript "
Saya harap artikel ini akan membantu pemrograman JavaScript semua orang.