Debug JavaScript/VB script (IE)

Source: Internet
Author: User
Tags what debugging

Javascript/VB ScriptScriptProgramGenerally there are two ways to execute, one is embedded in the Host Program for execution, for example, inIEExecute in the browser. In other words, double-click the execute in the Resource Manager (although it is explained and executed by another program, it gives people the feeling that it is running directly after all ).

Both methods can be used.Visual StudioDebugging:

1. to debug the script program on the webpage, the debugger needs the Host Program - here is ie In fact, all the script interpreters actually implement a com . The debugger can set breakpoints, query variables, and capture exceptions through this interface of the interpreter. Of course, the host Program must agree to this interface ...... As for how to implement this interface, we will discuss it in the Article in the future.

2.By default,IEIs to disable the script debugging support function, so you need to enable it explicitly. OpenIE, Click "Tools"-"InternetOption.InternetSelect the "advanced" tab, and find "Disable script debugging" in the "Settings" list (Internet Explorer). It is selected by default.-Remove it.

3. use ie to open a new webpage, or a local (open from a local hard disk) webpage. For example, save the following webpage as test.html :

1.<!Doctype Html Public "-// W3C // dtd xhtml 1.0 transitional // en" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

 

2.<Html Xmlns= "Http://www.w3.org/1999/xhtml">

3.<Head>

4. title > JavaScript debugging title >

5.<Script Language= JavaScript>

6.FunctionOnload (){

7.VaRTest = Unescape (Http://www.google.com");

8.Alert (test );

9.}

10.</Script>

11.</Head>

12.<Body Onload= "OnLoad ()">

 

13.</Body>

14.</Html>

 

4. Start Visual Studio , Click VS Tools in the menu" - Click "attach to process" to open the "attach to process" window. Visual Studio In fact, it supports many debugging modes. C ++ ( Native ) Program, debugging . Net (Managed) program, debugging script program, debugging Silverlight Program and debugging SQL Stored procedure. By default, Visual Studio The most suitable debugging mode will be selected based on the additional process type, but sometimes you need to set it manually. For example Internet Explorer This program, IE Multiple subprograms can be run simultaneously, IE Itself and ActiveX Control is C ++/C Written, IE Can run Winform/WPF Program, IE Can run Silverlight Program, of course, IE Run the most Javascript/VB Script Script program. Visual Studio When attaching Internet Explorer The process is always IE Confused, so we need to manually inform you Visual StudioWhat debugging mode do we want to adopt.

 

In the "attach to process" window..."(English isAttach...) Click "select" next to the text box and selectCodeIn the "type" window, select "debug the following types" and select "script ". As shown in:

 

5. Then you need to select the process to be appended in the "Attach process" window, in the "available process "( Available Processes ) In the list, there is a "type "( Type ) Column, which lists the debugging modes supported by the corresponding process. For example, you can see several Iexplore.exe Supports scripts and C ++ Debug mode ( Script, x86 ). So what you need to do is to find the process for executing the web page. Here I chose ID Is 3732 Of Iexplore.exe Because that is the process that runs the third-step webpage. Click "add "( Attach ) Button to debug the specified IE Process.

 

Note: Careful users may see, id 1692 iexplore.exe the title is" JavaScript debug" - the corresponding is the browser process for executing the web page id . In fact, before IE 8 , the browser processes for executing Web pages are generally based on the browser title, however, IE 8 there are some changes, which will be discussed in later articles.

6.After attaching7Line (page source code in step 3) sets a breakpoint-Just like normal debuggingC #AndC ++The Code is the same. After the settings are completeIEIn the process, refresh the web page. At this time,Visual StudioIt should be in7Line interruptionIEYou can "(Watch) View the script variable value in the window:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.