views:

65

answers:

1

My Problem: I have some Images in the div (ImageRoller)

In the variable "CurrentImage" i have saved a path to one of the image

By the function "ShowNextImage" i want to have the image path of the next image: ("Images/Frangipani Flowers.jpg")

It works in FF and all normal Browsers, but not in IE.

IE searches in this part (img[src='" +CurrentImage+ "']) not like all other browser for Images/Forest Flowers.jpg but rather a path like file:///C:/Users/MyUser/Desktop/jquery%20learning/Images/Autumn%20Leaves.jpg

How can I change this in IE to the short image path (Images/Forest Flowers.jpg), or is this even impossible?

Here the code:

<div class="ImageRoller">
  <img src="**Images/Forest Flowers.jpg**" />
  <img src="Images/Frangipani Flowers.jpg" />
  <img src="Images/Garden.jpg" />
  <img src="Images/Green Sea Turtle.jpg" />
</div>

    function ShowNextImage()
    {
 var CurrentImage = "Images/Forest Flowers.jpg";
 var ImagePathOfTheNextImage = $(".ImageRoller img[src='" +CurrentImage+ "']").next("img").attr("src");

 ShowImage(ImagePathOfTheNextImage);  
    }
+1  A: 

Try:

function ShowNextImage()
{
    var CurrentImage = "Images/Forest Flowers.jpg";
    if( $.browser.msie ) {
        var loc = document.location.href;   
        CurrentImage = loc.substring( 0, loc.lastIndexOf( '/' ) ) + CurrentImage;
    }
    var ImagePathOfTheNextImage = $(".ImageRoller img[src='" +CurrentImage+ "']").next("img").attr("src");

    showImage( ImagePathOfTheNextImage );
}
Jacob Relkin
This generates only the whole path of the imageI think the problem is in this area (.ImageRoller img[src='" +CurrentImage+ "'])this part searches the image with exact this path of "CurrentImage", but in IE there is no Image like this becauce it builds a the long image path
ValiL
My updated code should work.
Jacob Relkin
thank's alot that works^^
ValiL
Awesome! My pleasure. :)
Jacob Relkin