Pages

Search This Blog

Tuesday, June 14, 2011

Debugging Javascript code in Sharepoint

In order to debug Javascript code, you will first need to check the Internet options for Enabling/Disabling script debugging. You can follow below mentioned steps in order to do this:

In Internet Explorer, go to "Tools"-->"Internet Options", Under "Advanced" tab, look for the two options:

Disable Script Debugging (Internet Explorer)
Disable Script Debugging (Other)

Ensure that the two options are not checked (refer to the below screen shot).
























Now you can debug your javascript code by writing a word as "debugger;" anywhere in your javascript code. It will create a breakpoint automatically.When this breakpoint gets hit, your debugger will launch. You will see an error message that says “a runtime error’ has occurred in script”. There is nothing to worry about this, this actually allows you to select the application for debugging the javascript code.

There might be the case that even after doing above settings, you are not able to attach the debugger. For this you may need to check the Registry key for the appropriate dword settings.

Set the HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings named value JITDebug to 1 (DWORD).

Note: You might have to add both the Settings key and the JITDebug key if its not already there.

No comments:

Post a Comment