タイトルにあるように、Web ページでこの JavaScript 関数を呼び出す方法を見つけようとしています。これは私のビジネス用で、テンプレートは基本的な無料のものです。私よりも経験豊富な人にとっては、おそらく正しくフォーマットするだけの簡単な問題だと思います。これが私が取り組んでいるものです。
Web ページの HEAD 部分に入るコード:
var theImages = new Array()
theImages[0] = 'splash1.jpg'
theImages[1] = 'splash2.jpg'
theImages[2] = 'splash3.jpg'
theImages[3] = 'splash4.jpg'
theImages[4] = 'splash5.jpg'
theImages[5] = 'splash6.jpg'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}
</script>
次に、使用する関数を呼び出します。
<SCRIPT LANGUAGE="JavaScript">
showImage();
</script>
これを実装しようとしているページは次のとおりです。 http://coloradopp.com/index4.html
画像を表示するだけでなく、その関数を呼び出したいと思います。スプラッシュ 1 ~ 6 はすべて元の画像と同じサイズです。
コード スニペットは次のとおりです。
<div id="splash">
<img class="pic" src="images/splash1.jpg" width="870" height="374" alt="" />
</div>
ご覧のとおり、ページはすべての書式設定のためにスタイル シート (style.css) を呼び出します。
これを機能させる方法について誰かがヒントを提供できますか? 私が集めたものから、javascript を css シートに実装することはできません。前もって感謝します。