繁体   English   中英

在javascript数组中显示行数(幻灯片中的图片)

[英]display number of lines (pictures in slideshow) in javascript array

我修改了幻灯片的以下代码以与灯箱配合使用,对我来说非常有用。

唯一缺少的是显示多少张照片的东西。

在幻灯片旁边显示一个简单的数字,如“ 15”会很好,两个数字如“ 7 of 15”会很酷,绝对的刻录机将是缩略图,突出显示的图片。

好的,这是完整的代码。 我把功劳留在了这里。我想知道有多少张“ ulitmateshow [x]-图像”。

由于我对Java语言没有任何了解,因此将不胜感激。


编辑:有人知道如何显示显示图片的编号吗? 然后我们将处于“酷”阶段

// Flexible Image Slideshow- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use

var ultimateshow=new Array()

//ultimateshow[x]=["path to image", "OPTIONAL link for image", "OPTIONAL link target"]

ultimateshow[0]=['images/image_1_x.jpg', 'images/image_1_b.jpg', '', 'lightbox[image]', 'title blabla']
ultimateshow[1]=['images/image_2_x.jpg', 'images/image_2_b.jpg', '', 'lightbox[image]', 'title blabla']
ultimateshow[2]=['images/image_3_x.jpg', 'images/image_3_b.jpg', '', 'lightbox[image]', 'title blabla']
ultimateshow[3]=['images/image_4_x.jpg', 'images/image_4_b.jpg', '', 'lightbox[image]', 'title blabla']
ultimateshow[4]=['images/image_5_x.jpg', 'images/image_5_b.jpg', '', 'lightbox[image]', 'title blabla']

//configure the below 3 variables to set the dimension/background color of the slideshow

var slidewidth="500px" //set to width of LARGEST image in your slideshow
var slideheight="334px" //set to height of LARGEST iamge in your slideshow
var slidecycles="continous" //number of cycles before slideshow stops (ie: "2" or "continous")
var randomorder="yes" //randomize the order in which images are displayed? "yes" or "no"
var preloadimages="yes" //preload images? "yes" or "no"
var slidebgcolor='#c0c0c0'

//configure the below variable to determine the delay between image rotations (in miliseconds)
var slidedelay=3000

////Do not edit pass this line////////////////

var ie=document.all
var dom=document.getElementById
var curcycle=0

if (preloadimages=="yes"){
for (i=0;i<ultimateshow.length;i++){
var cacheimage=new Image()
cacheimage.src=ultimateshow[i][0]
}
}

var currentslide=0

function randomize(targetarray){
ultimateshowCopy=new Array()
var the_one
var z=0
while (z<targetarray.length){
the_one=Math.floor(Math.random()*targetarray.length)
if (targetarray[the_one]!="_selected!"){
ultimateshowCopy[z]=targetarray[the_one]
targetarray[the_one]="_selected!"
z++
}
}
}

if (randomorder=="yes")
randomize(ultimateshow)
else
ultimateshowCopy=ultimateshow

function rotateimages(){
curcycle=(currentslide==0)? curcycle+1 : curcycle
ultcontainer='<center>'
if (ultimateshowCopy[currentslide][1]!="")
ultcontainer+='<a href="'+ultimateshowCopy[currentslide][1]+'" target="'+ultimateshowCopy[currentslide][2]+'" rel="'+ultimateshowCopy[currentslide][3]+'" title="'+ultimateshowCopy[currentslide][4]+'">'
ultcontainer+='<img src="'+ultimateshowCopy[currentslide][0]+'" border="0">'
if (ultimateshowCopy[currentslide][1]!="")
ultcontainer+='</a>'
ultcontainer+='</center>'
if (ie||dom)
crossrotateobj.innerHTML=ultcontainer
if (currentslide==ultimateshow.length-1) currentslide=0
else currentslide++
if (curcycle==parseInt(slidecycles) && currentslide==0)
return
setTimeout("rotateimages()",slidedelay)
}

if (ie||dom)
document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>')

function start_slider(){
crossrotateobj=dom? document.getElementById("slidedom") : document.all.slidedom
rotateimages()
}

if (ie||dom)
window.onload=start_slider

使用数组对象的length属性。

var imageCount = ultimateshow.length;
console.log(imageCount) //logs image count

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM