Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer 8 error - Expected Identifier, string or number - JQuery

Wondering what to do about this. Googling but can't seem to find anything. I am using the Cycle Plugin for JQuery and works great in all browsers but IE of course. Same problem in IE 6, 7, and 8.

Expected identifier, string or number referring to line 13 of my js file. Anyone know what to do here?

js file:

$(document).ready(function() {
    $('.slideshow').cycle({
  speed:  200,
  timeout: 15000, 
  pager:  '#tabs',
  pagerEvent: 'mouseover',
  pauseOnPagerHover: true,
  pagerAnchorBuilder: function(i, slide){// callback fn for building anchor links:  function(index, DOMelement) 
    return '<a href="path-to-link"><img src="../images/tabback.png' + slide.src + '" height="47" width="189" /></a>';
},


 }); <------THIS IS LINE 13
});
like image 853
bgadoci Avatar asked Jan 18 '10 21:01

bgadoci


3 Answers

Remove the , after your pagerAnchorBuilder callback.

like image 71
prodigitalson Avatar answered Sep 28 '22 06:09

prodigitalson


Oh Oh, I know this one. There is an extra , at the end of line 12 which IE doesn't like. I have had this bite me multiple times.

It is always a good idea to put your javascript through jslint.

like image 41
abhaga Avatar answered Sep 28 '22 08:09

abhaga


I know it's been posted 2 years ago and is already answered. But I had a different reason for the same error message on the same browser, so I thought I'd share how I fixed my issue.

I just had the same error in IE8 and older (newer IE and all other clients were fine). The reason I was getting it was not the last comma in static var or function definition. I named one of my variables "class". IE8 and older don't like that, their interpreters throw the same "Expected Identifier, string or number" error when they try to parse that name. So, if you have anything named "class" in your script and get that error, just rename that thing to something else.

like image 39
Kizz Avatar answered Sep 28 '22 07:09

Kizz