Get a 25% off coupon to use on any of our website scripts! - Subscribe to our Newsletter now!
Free Web Site Evaluations
Home » Scriptalicious Blog » News » Expected Identifier, String or Number

Scriptalicious Blog

Expected Identifier, String or Number

Posted 2009-04-05 in News

Scriptalicious Blog

Internet Explorer gives the JavaScript error “Expected indentifier, string or number” when it’s expecting another variable. Firefox and Safari don’t have such a problem, but it’s easy to fix the error in your JS code if you can find where it’s located.

In order to fix the “Error: Expected identifier, string or number” message in IE you must remove the last comma from your object lists. For example (comma marked in blue):

var myObject = {
    myvar : 10,
    init : function() {
        // Init code
    },
    myFunction : function() {
        // Function code
    },
};

Remove the comma above and our code works fine in IE, Firefox and Safari:

var myObject = {
    myvar : 10,
    init : function() {
        // Init code
    },
    myFunction : function() {
        // Function code
    }
};

I found a basic solution to this posted here, but the tough part is finding out where the error is being generated if you’re running a lot of JavaScript code. Internet Explorer’s JS error message tells you the location of the error (You can click “Error on page” in the browser status bar to see the full error if not already presented).

The “Line: xx” and “Char: xx” values tell you exactly where the error is occurring, but it only tells you the line and character position in the JS file being executed. If you’re including multiple JavaScript files try removing all but one and then adding them back again until the error pops up. Then find the line in that file and hopefully your error will be right there!





 


Search



Subscribe


Subscribe via RSS

Stay current with Scriptalicious news and subscribe in your favorite RSS reader.

Subscribe by RSS

Subscribe via Email

Get the latest Scriptalicious news delivered to your inbox.




77 powerful SEO scripts for under $100.

Real-time Backlink Rank Checker script.


Scriptalicious is in no way affiliated with myspace.com® or Google®. Google, PageRank™ and MySpace are the trademarks of their owners.