当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - JQuery not adjusting image src in IE and Firefox, only in chrome

问题描述:

I've created an image gallery which works as expected in Chrome, but does not work at all in firefox or internet explorer. I've had a look around at some similar questions but I don't believe they are especially helpful in solving this issue.

I've created a JFiddle of the code:

https://jsfiddle.net/ydmgjzwp/

I'm guessing the code which is causing the issue is:

function updateMainImage(){

var selected = imageController.selectedImageObject;

var currentImageObject = imageController.imageObjects[selected];

var newImage = currentImageObject.image;

$(imageController.mainImageImg).attr("src", newImage);

}

In IE and FF the main image at the top does not load at all. It ought to be changed, via JQuery, to the first of the smaller images, and then whichever the user selects.

I haven't noticed anything too useful in the console logs, but again I may be missing something. Any help that anyone can offer is VERY much appreciated.

网友答案:

replace this function

function trimCssUrlSyntax(inputString) {
                    var returnString = inputString.replace('")', '');
                    returnString = returnString.replace('url("', '');
                    return returnString;
                }
网友答案:

You have double quotes on your image src. I change your function and works.

function trimCssUrlSyntax(inputString){
      var returnString = inputString.replace(")", );
      returnString =  returnString.replace("url(", );
      return returnString;
    }

DEMO HERE

分享给朋友:
您可能感兴趣的文章:
随机阅读: