4

The following script below is not running in IE7 but works perfectly fine in IE 8 + 9 and ALL other browsers. Even putting in the alert("something"); does not work - I have another script that is working fine and that is running in IE 7 perfectly.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

Am I missing a DOCTYPE? Here is the script below;

var formPageTitle = $("div.hsRadarform td h3").text(); 

$('.AspNet-DataList td a').each(function (index) {        
    var listElementText = $(this).text();
    var shade = "faint";

    if(formPageTitle.toLowerCase() == listElementText.toLowerCase()) {
        shade = "dark";
    }

    //adding the numbered circles here using jQuery
    $(this).css({ 
        'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
        'background-repeat': 'no-repeat',
        'height': '25px',
        'width': '25px',
    });
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
mjcoder
  • 1,009
  • 9
  • 25
  • 45

1 Answers1

14

IE is very picky with trailing commas :

$(this).css({ 'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
    'background-repeat': 'no-repeat',
    'height': '25px',
    'width': '25px',
});

Should be

$(this).css({ 'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
    'background-repeat': 'no-repeat',
    'height': '25px',
    'width': '25px' // comma removed
});
Manse
  • 37,765
  • 10
  • 83
  • 108
  • that comma was causing the problem - working now in all browsers - not bothering with IE6. One little comma and IE is very picky - they shouldnt be too picky - they could drive people crazy LOL. Cheers - will mark it as the answer - wont let me just now only afer 5 minutes. – mjcoder Dec 02 '11 at 13:52
  • "they could drive people crazy" they do ... I deal with anomalies between IE / Firefox / Safari and Chrome on a daily basis ... – Manse Dec 02 '11 at 13:57
  • i have TR and TD's inside that when i give it a float: left; i want it to display all on one line - for some reason its not having it in IE7 - IE 8 + 9 is fine - no tweaking is needed there. – mjcoder Dec 02 '11 at 14:27
  • @c-sharpnewbie Sorry but I dont quite understand you question - your better off raising another question on here with some source ... – Manse Dec 02 '11 at 14:30
  • never mind had a look around - seems you cant float TD or TR elements in IE7 (I'll just hide it) thanks for your help, enjoy the rest of your day. – mjcoder Dec 02 '11 at 14:33