1

そこで、lightroom 用の slideshowpro に 35 ドルを支払う代わりに、単純なタスクを実行するために簡単な JavaScript スライドショーを作成することにしました。div 内の 10 個の画像をランダムに回転します。次のように機能します。

var imageSrc = "source_folder/";
var imageType = ".jpg";
var randomImage = imageSrc + 0 + Math.floor(#*Math.random()) + imageType;

(これはすべてのコードではありません。残りは省略しています)

タグを取得randomImageして挿入するにはどうすればよいですか。<img>

src="randomImage" will not work.
4

3 に答える 3

0

Don't use the string "randomImage", use the variable:

image.src = randomImage

This is just setting the src to the path of the current image. There will be a delay as the images are loading. You could preload paths using new Image().src = [path], or use image sprites and css clip to make it more seamless.

于 2009-11-14T03:31:47.420 に答える
-1

I highly recommend jQuery and the Cycle plugin.

于 2009-11-14T03:32:18.463 に答える