Difficulty in Understanding Slideshow script

后端 未结 1 822
名媛妹妹
名媛妹妹 2021-02-02 05:10

I have taken slide show script from net. But There some functions i cannot understand here is script



        
1条回答
  •  渐次进展
    2021-02-02 05:31

    Ok I figured it out. My code had many errors.

    imageItem is a constructor function designed to preload images. It returns the src (location) of the image that it preloads.

    However the function get_ImageItemLocation() assumes that imageItem has returned an object.

    The whole thing should simplify to:

    
    
    
    
    
    
    
    
    
    
    Play slide show |  Pause |  Previous |  Next  

    Well If you want imageArray to be an array of image urls, then the simplest way is: ...

    function imageItem(url) {
        var img = new Image();
        img.src = url;
        return url;
    }
    for(var i=0; i<5; i++){
        imageArray[i] = imageItem(imageDir + i + ".jpg");
    }
    

    Note how imageItem is called without new in this case. Hope you will understand it now. Let me know if you have further problem with this code.

    0 讨论(0)
提交回复
热议问题