Link to home
Start Free TrialLog in
Avatar of sharpodal
sharpodal

asked on

Javascript debugging

I look thru the other question in this site which offered help on Javascript debugging:

Here is the extract from that location:
<extract>
Script debugging is turned off by default you can enable it by going to:
Tools->Internet Options…->Advanced->Disable Script Debugging

Prior to XPSP2 the above will turn script debugging on for all applications that host the WebBrowser control (Outlook for example).

On XPSP2 we’ve split the option into two:
Tools->Internet Options…->Advanced->Disable Script Debugging (Internet Explorer)
Tools->Internet Options…->Advanced->Disable Script Debugging (Other)

When you’ve enabled Script Debugging ‘View->Script Debugger’ will now be present to help you break into the debugger.

The debugger statement can also be placed anywhere in your code to suspend execution this is similar to setting a breakpoint.
The Stop statement is the VBScript version of JScript’s debugger statement.

<extract>

I installed the Microsoft Script debugger and I enable script debugging by
unchecking the below two:
Tools->Internet Options…->Advanced->Disable Script Debugging (Internet Explorer)
Tools->Internet Options…->Advanced->Disable Script Debugging (Other)


I do not see the below behavior. Do i need to do anything additional ?
When you’ve enabled Script Debugging ‘View->Script Debugger’ will now be present to help you break into the debugger.

Apart from the above I set the

debugger statement as below:

   function btnDivide_Clicked()
   
   {    
     
        var intNumber1 = 0;
        var intNumber2 = 0;
        var intResult = 0;
                  
        intNumber1 = document.all('txtNumber1').value;
           debugger;
        intNumber2 = document.all('txtNumber1').value;
        intResult = intNumber1/intNumber2;
        document.all('txtResult').value = intResult;
        return false;
    }

But it never stops at the debugger.

Please let me know whether i am missing out on something whichh prevents me to debug in VS 2005.


Avatar of prairiedog
prairiedog
Flag of United States of America image

The Script Explorer should be under Debug-->Windows menu, if not there, then you need to manually add it:

    * Tools -> Customize
    * Select the Command Tab
    * Select Debug from the list, and on the right hand side, select Script Explorer
    * Drag this somewhere useful, like your Debug Toolbar/Menu
I use the addon Firebug for debugging js in Firefox.

btw, document.all is IE only. if you want an x-browser supported method use document.getElementById

this could be the bug you are looking for. :-)
Avatar of sharpodal
sharpodal

ASKER

Let me clarify my question further on what i really need
 I have added the "debugger" statement in the code but i am not able to debug in VS 2005. I am interested to know how to debug this script with VS 2005. I have already installed the Microsoft Script Debugger and then tried for debugging but I am neither able to out a break point or stop at the location desired for debugging

function btnDivide_Clicked()

{

var intNumber1 = 0;
var intNumber2 = 0;
var intResult = 0;

intNumber1 = document.all('txtNumber1').value;
debugger;
intNumber2 = document.all('txtNumber1').value;
intResult = intNumber1/intNumber2;
document.all('txtResult').value = intResult;
return false;
}
You should be able to add a break point in your JavaScript code, then run your application in the debug mode. When your application calls the JavaScript, it will stop at the break point. This is what I use in my applications, but I never used the debugger and don't know much about it.
Do i need to do any thing specific to debug in VS 2005 ?
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial