この記事では、JSがページの読み込みを実装したときの画像効果のランダム表示について説明します。次のように、参照のために共有してください。
<html> <head> <title> jsランダム画像効果</title> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"> <style type = "text/css"> <! - img {border:#99999;ボーダースタイル:点線;ボーダートップウィッド:1px;境界線幅:1px;境界線幅:1px; border-left-width:1px} - > </style> </head> <スクリプト言語= "javascript"> var userand1 = 0; var userand = 0; images = new Array;画像[1] =新しい画像(); src = "img/a1.jpg"; emages [2] = emage [2]; emage [2]; emage [2]; emage [2]; emage [2] "impg ="。 = new Image(); image [3] .src = "img/a3.jpg"; images [4] = new image(); mage [4] .src = "img/a4.jpg"; function swappic(){var imgnum = imgnum = imgnum = imgnum = length -1; do {var randnum = math.random() while(rand1 == userand); userand = rand1; document.randimg.src = images [userand] .src;} </script> <body bgcolor = "#ffffff" text = "#000000" onload = "swappic()"> <img name = "randimg" src = "img/a1.jpg> </</</</<コードはテストされ、正常に実行されます。ここにはランニングレンダリングがもうありません。興味のある友達は、美しい女性の写真をいくつか選択して、それらをテストして効果を確認できます。
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構造とアルゴリズムのスキル」および「JavaScriptの数学的操作の使用の要約」
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。