To debug Javascript in A SharePoint environment, consider the following settings:
1. First, you need to check whether your IE has enabled script debugging.
In Internet Explorer, find "Tools" --> "Internet Options", find the "advanced" page, and find the following two items under this page:
Disable script debugging (Internet Explorer)
Disable script debugging (other)
Make sure these two items are not selected.
2. For the ecmascript Object Model in Sharepoint, you will findArticleYou need to set the Web. config and machine. config of webapplication respectively.
They are modified to support debugging by loading the JS files of the debug version.
You can useHereTo learn more.
2.1 modify web. config to describe how to set up relevant articles on the Internet, but I have not set this for my environment. The reason is described later.
This web. config file is in the directory % inetpub % \ wwwroot \ WSS \ virtualdirectories \ [yourwebsiteport]
Find the system. web section in this file and add the followingCode
< Deployment Retail = "False" />
The modified web. config effect is as follows:
If you set this parameter, the following error occurs when you run your SharePoint application:
It is an error to use a section registered as allowdefinition = 'machineonly' beyond machine. config
Errors include:
This option should be provided only in machine. config to prevent users from modifying it. Therefore, for my environment, I have not set this web. config.
To load the debug version of JavaScript, you also need to set debug to true in <compilation batch = "false" DEBUG = "true">.
2.2 modify machine. config
This file is in the directory c: \ windows \ Microsoft. NET \ framework \ v2.0.50727 \ config \
Find the following code for this file:
< Section Name = "Deployment" Type = "System. Web. configuration. deploymentsection, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a" Allowdefinition = "Machineonly" />
Delete allowdefinition = "machineonly" and change it
< Section Name = "Deployment" Type = "System. Web. configuration. deploymentsection, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a" />
The modified file is as follows:
3. Now you can add a debugger anywhere in your JavaScript code and set a breakpoint to activate your debugger.
When your breakpoint is hit, a window will pop up for your SharePoint website, asking you to start the corresponding debugger, such:
After you select debugger, you can view and debug your JavaScript breakpoint, for example:
If you cannot attach the key to the debugger as expected, you can view your registry settings and find the following key:
HKEY_CURRENT_USER \ Software \ Microsoft \ Windows Script \ Settings
Set the value of jitdebug (if not, add it) to 1.
4. Of course, we can also start Developer Tools in IE to debug our JavaScript/ecmascript.
For detailed operation methods, refer to this article
SharePoint learning notes-ecmascript object model series-3. How to view all methods of the SP object)