Sunday, August 7, 2011

IE7 Error: Expected identifier, string or number

Most developers are suffering from IE7 compatibility issue. Most of the time, we encounters error when doing javascript. One of the error I encountered was "Expected identifier, string or number".

This error is due to IE expecting a data. For the sake of this post, I will use the jcarousel plugin passing the parameters we need.

<script type="text/javascript">
$(document).ready(function() {
    $(".carousel").jCarouselLite({
        visible: 3,
        btnPrev: 'a.prevbtnHome',
        btnNext: 'a.nextbtnHome',
    });
});
</script>

As you can see on the sample JS above, we are passing parameters ending all with comma ",". This approach will actually work on most browsers but not on IE7 and below.

To resolve this, you just need to remove the comma "," on the last parameter.

<script type="text/javascript">
$(document).ready(function() {
    $(".carousel").jCarouselLite({
        visible: 3,
        btnPrev: 'a.prevbtnHome',
        btnNext: 'a.nextbtnHome'
    });
});
</script>

Hope this post helps a lot!

No comments:

Post a Comment