IE error: Expected identifier, string or number
I have made this mistake a couple of times and it's one of the most annoying IE errors:
The error throw will look like this (in IE 7):
How to reproduce itIf you put an extra comma in a object or list definition the above error will be raised in IE. Example: a = {
b: function() { },
c: function() { },
}
//Or
a = [1,2,3,4,];
I.e. the extra , confuses IE, but not the other browsers. To fix it, simply don't write the extra comma. Catching these automaticallyTo catch these I use following function: import re
obj_close = re.compile(".{0,15}\},\s*\}", re.MULTILINE)
arr_close = re.compile(".{0,15},\s*\][^/]", re.MULTILINE)
def invalidJSseperators(js):
all_obj_errs = obj_close.search(js)
all_arr_errs = arr_close.search(js)
return all_obj_errs, all_arr_errs
Code
·
JavaScript
•
15. Jan 2009
Post a comment
Commenting on this post has expired.
|
Blog labels |