Need to find actual location of line/char in Internet Explorer Script errors?

前端 未结 4 1677
难免孤独
难免孤独 2021-02-19 16:41

I\'m receiving a script error in IE:

Line: 59 Char: 71 Error: Expected identifier, string, or number Code: 0

Line 59, character 71 don\'t seem to actually corres

4条回答
  •  误落风尘
    2021-02-19 17:08

    I've found IE Line # / Char #'s to be useless or more hassle then it's worth.

    If you're including multiple javascript files and all it gives you is a line # and char # it's alot of work to concatenate all the scripts together to figure it out where the error is.

    If I can find the error in firefox using firebug then that's the easiest way. If it's an IE only problem what I do is enable script debugging in Internet Options,

    1. Go to Tools->Internet Options…->Advanced->Disable Script Debugging (Internet Explorer)

    2. Go to Tools->Internet Options…->Advanced->Disable Script Debugging (Other)

      then attach Visual Studio Debugger when an error occurs.

    If you're using IE 8, install the developer toolbar because it has a built in debugger.

    If you are really keen on not using a debugger and just viewing the source and getting the line # you can try View -> Original Source in the IE Developper toolbar.

    In your case you gotta watch out for trailing comma's in object literals

    var obj = { 
    a: 1, 
    b: 2,
    }
    

    Or naming a variable with a reserved keyword like "class", that has burned me many times. Here is a list of reserved keywords

提交回复
热议问题