Javascript "Match" Function Not Returning Proper Results in Safari or IE (but yes in FF)

Posted by Jascha on Stack Overflow See other posts from Stack Overflow or by Jascha
Published on 2010-05-07T07:23:06Z Indexed on 2010/05/07 7:28 UTC
Read the original article Hit count: 256

Filed under:

Forgive me as this is a time sensitive issue and I will have to switch the site back in a few hours so the link will be bad... but:

I am simply comparing two strings looking for a match with this function...

I have an array of objects called linkArray and I need to match the .src of each object to a .src I send it (the src of the clicked image). if the the src of the image I clicked matches the src of an object in my array, I set a variable to the link string of that object and return true, letting my page know that the link is available. Now, this works great in FF. But not in any other browser and I can't figure out for the life of me why. I have set up a dialogue box to literally compare, by eye, the two strings that should at the very least throw the message "match". Can anyone see what I am missing here???

here is the link... http://7thart.com/Jewish-History-and-Culture/Jews-and-Baseball-An-American-Love-Story

If you click any of the thumbnails on the left, you will activate the function. Again, I apologize as after a few hours I have to switch back to the original site and this link will be invalid. Thanks in advance for your help. (function below)...

function matchLink(a){
    for(var i=0;i<linkArray.length;i++){
        var fixLink = '../' + linkArray[i]['src'];
        alert(fixLink + '\n = \n' + a);
        if(fixLink == a){
                    alert('match');
            newLink = linkArray[i]['link'];
            return true;
        } 
    }
    return false;
}

Note: The "match" will return on two of the images.. the initial image, and the first thumbnail on the left. The second thumbnail SHOULD match, and the third one SHOULD NOT match.

© Stack Overflow or respective owner

Related posts about JavaScript