Debugging a javascript error that only occurs on the live site - javascript

Something broke and I get "Object Expected" error on my live site, but I can't figure out where. If I run visual studio at the same time, it breakpoints it and shows the error as being half way along the viewstate, highlighted yellow... which is useless as its just gobbledegook.
How can I debug this? I want to know what javascript its trying to run that is breaking it.

Firefox and Firebug.
http://getfirebug.com/
Never debug Javascript without it.

Check out ScriptCanary.com so you can get all the details from live site errors and vastly improve your chances of quickly fixing them.

Related

applescript: do javascript fails on OSX10.8.4?

After OSX 10.8.4 update, this small script stopped working
tell application "Adobe Photoshop CS6"
do javascript "alert('hello world')"
end tell
Can anyone confirm it's a change in AppleScript syntax introduced in last updated,
or I'm missing something?
Can your reproduce this script on OSX 10.8.4?
The exact error I get is:
Syntax error
Expected end of line but found identifier.
And JavaScript is highlighted.
I just struggled with a similar problem in Illustrator CC on 10.8.5 for a few hours.
I was running the script through a shell command in a .sublime-build file (Sublime Text 2).
Running the same basic script once from the official AppleScript Editor subsequently fixed it.
I still need to investigate why. If you have an idea, please comment.
I think the problem your experiencing is due to the fact that you have to specify a tab for applescript to run the JS code in. For example:
do JavaScript "alert('Hey');" in tab 1 of front window
If you don't specify which tab to run the javascript code in, it always throws the same 'identifier' error.
Hope this helps. (I've been frustrated by this one myself. It's easy to forget)
--Sorry, just realized you were talking about Illustrator. My mind immediately went to Safari's 'do javascript'.

How do you debug IE & jQuery errors like this

I'm developing in Javascript for quite a long time now. Usually when I hit an error in IE I know roughly where it originated even if the message received from IE is useless bunch of text. When I don't know where the error originated, I usually try to "delete" parts of my code, until the error doesn't repeat itself, and that start manually checking line by line until I find the error.
I'm sure that it's far from the best approach, so I'd like to ask you how you debug error like these:
If you are using IE8+, you can press F12 on a page to open the Developers Tools.
This contains a JavaScript debugger, much like Firebug & Chrome Dev Tools
EDIT:
In response to the comment under the question, if IE is throwing a cryptic error that you are unsure of, there is a couple of steps I would do.
Is it an IE only error? Does the same error occur in Firefox? Chrome?
Is the error occurring in a 3rd party library. If you believe it is, use an un-minified version of the library.
Can you replicate the error outside of your website? Can you make the error occur in a http://jsfiddle.net/ for instance?
If you still can't narrow down the issue, post a question on SO with your code, any error messages, and expectations of the result.
HTH
Try using non-minified version of jQuery - it will give you a better idea where exactly the error is. Also, if you use VS 2010 to debug your js code in IE, it will break at the error line. This always works fine for me.
IE is the only browser that I've managed to successfully use the fantastic Visual Studio script debugger with - in my experience Visual Studio is hands down the best script debugger out there, so quite often I find myself in the reverse situation to you (running broken scripts in IE just so I can use the script debugger)
See How to debug JavaScript in Internet Explorer for instructions on how to use Visual Studio Express to debug scripts in IE - if you own a full edition of Visual Studio then its much simpler (just attach to IE as normal).

Microsoft Script Debugger does not display any information after error

I'm trying to debug a Javascript error which only occurs in Internet Explorer. I have Microsoft Script Debugger installed, and have used it successfully in the past. On this error, though, I select "Yes" to do-you-want-to-debug?, and it opens up Script Debugger, which displays nothing. Running documents window is empty, call stack is empty, as though nothing is being debugged.
Can anyone tell me what causes this?
I've had these sorts of issues before with the Microsoft Script Debugger but never managed to find a solution - if you have a license the script debugger inside Visual Studio 2008 is far far better.
There is an article here about how you can use VS 2008 Express (free) as a script debugger.
I've seen this issue with code inside a try/catch/finally block--for some reason the debugger gets confused by the finally block. Try commenting them out.
I know this is old but I thought I would point out that this is still an issue. Microsoft plain sux. Developers are being forced to support products that are broken....this is a crime

Is there a way to get more detailled JS error messages in IE7?

When there is a JS error in IE7, the text displayed is not helpful mainly because it says "error at line X" but the line doesn't really correspond to anything if you start including multiple javascript files.
Is there an option or add-on that could maybe improve this?
I haven't found anything in IE7. However, if you have the option, IE8 + web developer toolbar makes it a lot easier, as the web dev toolbar includes a javascript debugger. Most of the time I see the same errors in IE 7 and 8, so debugging them in 8 usually leads to fixing it in 7 as well.
The only extra detail you can get is by turning on the script debugging. You can do this through Internet Options - Advanced - uncheck Disable Script Debugging (Internet Explorer). This will pop up an alert whenever you get an error and you can see the line of code that created it as well as step through the code's execution.
All that I have found helpful is turning on the debugging. You can then sometimes step through the code to the problem. It seems to be hit or miss though, as to whether it actually works or not.

IE and unspecified error and in IE8 object doesn't support method

I have a big (probably) javascript problem.
i have a long and complex script on the page based on mootools framework,
in FF and other browser everything works fine, but in ie 6 and 7 i got "error:153 (sometimes 84) Unspecified error" and the strange thing is in IE8 that show me the error "Object doesn't support this property or method".
someone know the possible cause of the problem? o maybe someone know a list of IE's unsupported property or method?
In IE8 you can get the line number of the error, then right-click -> view source. IE8 has a proper source, which includes script lines, so you should quickly be able to find the source of your error.
If the script you're using isn't obfuscated or all on one line, you could use the JavaScript debugger in IE8 to pinpoint the object which is causing the error. Press F12 to open the Developer Tools, go to the Script tab, and click the "Start Debugging" option. If there's an error it may well break on the relevant line. If not you can set some breakpoints and step through the code.
You can also use IE8 developer tools http://blogs.msdn.com/ie/archive/2008/09/03/developer-tools-in-internet-explorer-8-beta-2.aspx to debug.
For other version I suggest you use Web developer tool bar which is similar to web developer tool bar for firefox.
Its near impossible to tell what the problem is with this information (at least for me).
For IE6/7 I suggest adding a few alerts to the javascript in intervals to find out exactly what line of code is causing your problem. If you know which object is causing the error, it is usually quite simple to find out what the exact problem is.
IE8 provides nice debugging tools, so that is a good place to start.
In my case the error was due to a $ mapping conflict.
Using jQuery instead of $ solved the issue.

Categories

Resources