Click here to Skip to main content
13,249,087 members (39,220 online)
Click here to Skip to main content
Add your own
alternative version


Posted 4 May 2011

How to fix JavaScript Errors

, 8 May 2011
Rate this:
Please Sign up or sign in to vote.
Several methods to debug JavaScript


I have always seen people asking questions on JavaScript. If we know how to debug JavaScript like any other programming language, we don't need much help on this topic.

How to Solve the Problem

First Method

So here is the trick: .NET has given us the facility to debug JavaScript, but before that, we need to do some settings in Internet Explorer.
  • Tools → Internet Options → Advanced Tab
  • Uncheck Disable script debugging (Internet Explorer) & Uncheck Disable script debugging (Others) and restart Internet Explorer

Now in a Visual Studio Project, on the aspx page in the script blog, type the debugger keyword as shown below:
function Disable(controlId) {
      document.getElementById( = true;"second.htm");

Now open your page in Internet Explorer and try to execute the function, so if the JavaScript is called on a button click, click the button. Now you will see a pop up which would give you a Visual Studio just-in-time debugger. Now select the Visual Studio instance where you want to debug JavaScript in, and click on yes and try to solve your problem.

Second Method

Another way is to replace the debugger keyword with any word which would give a JavaScript error. Let us look at it with the same example given above.
function Disable(controleid) {
      document.getElementById( = true;"second.htm");

Now in this case, instead of showing you the JIT debugger, it would give you the error asking "Do you want to debug this web page?", along with some error details. Click on "yes" and it will show you the JIT debugger.

Third Method

If this process is lengthy, then you can use the Developers Tool given in Internet Explorer. You will find it in
Tools → Developer Tools, or simply press F12.

Now go to the script tab. Just like you place debug pointer in Visual Studio, place a debug point on the left hand side corner on the place where you want to debug, and click on start debugging to start debugging your code.

For Firefox, install the Firebug add-on. You will see Firebug in tools, and also on the right corner of the browser.

You get developer tools for almost all browsers so now you can check and debug your JavaScript.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Social Group (No members)

You may also be interested in...

Comments and Discussions

GeneralReason for my vote of 4 useful about debugger keyword Pin
seaplanner11-Oct-11 6:24
memberseaplanner11-Oct-11 6:24 
Generalcool :) Pin
Shahriar Iqbal Chowdhury8-May-11 11:30
memberShahriar Iqbal Chowdhury8-May-11 11:30 
GeneralNice. Pin
Shahista.Shaikh7-May-11 4:29
memberShahista.Shaikh7-May-11 4:29 
GeneralRe: then you can rate me Pin
Steven.Pinto9-May-11 2:09
memberSteven.Pinto9-May-11 2:09 
GeneralWill be handy! :thumbsup: Pin
S Mewara6-May-11 20:50
mvpS Mewara6-May-11 20:50 
GeneralRe: Thank you Pin
Steven.Pinto6-May-11 21:04
memberSteven.Pinto6-May-11 21:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 8 May 2011
Article Copyright 2011 by Steven.Pinto2000
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid