|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
.NET 2005How can I debug javascript code on a page while the page is running?
Thanks, Victor <lasalsatx@newsgroups.nospam> wrote in message
news:u9z5DET0GHA.4252@TK2MSFTNGP03.phx.gbl... Use the JavaScript debugger method...> How can I debug javascript code on a page while the page is running? E.g. <script> var strMessage="Hello"; debugger; alert(strMessage); </script> Run your app in debug mode (F5, not Ctrl-F5), and execution will stop on the debugger; line. Hi,
Mark Rae wrote: Show quote > <lasalsatx@newsgroups.nospam> wrote in message I would rather recommend a method which doesn't need to modify the > news:u9z5DET0GHA.4252@TK2MSFTNGP03.phx.gbl... > > >>How can I debug javascript code on a page while the page is running? > > > Use the JavaScript debugger method... > > E.g. > > <script> > > var strMessage="Hello"; > debugger; > alert(strMessage); > > </script> > > Run your app in debug mode (F5, not Ctrl-F5), and execution will stop on the > debugger; line. source code: Simply put a breakpoint in the code... HTH, Laurent -- Laurent Bugnion, GalaSoft Software engineering: http://www.galasoft-LB.ch PhotoAlbum: http://www.galasoft-LB.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch "Laurent Bugnion" <galasoft***@bluewin.ch> wrote in message You're right, of course. It's an old (and, no doubt, bad) habit of mine from news:euH5cGa0GHA.2516@TK2MSFTNGP06.phx.gbl... > I would rather recommend a method which doesn't need to modify the source > code: Simply put a breakpoint in the code... back in the day when this was the only reliable way of debugging JavaScript... Did you ever try to set a breakpoint in JavaScript in Visual Studio 6...? Show quote :-) Hi,
Mark Rae wrote: Show quote > "Laurent Bugnion" <galasoft***@bluewin.ch> wrote in message Never had to do that ;-)> news:euH5cGa0GHA.2516@TK2MSFTNGP06.phx.gbl... > > >>I would rather recommend a method which doesn't need to modify the source >>code: Simply put a breakpoint in the code... > > > You're right, of course. It's an old (and, no doubt, bad) habit of mine from > back in the day when this was the only reliable way of debugging > JavaScript... > > Did you ever try to set a breakpoint in JavaScript in Visual Studio 6...? > :-) Back in the days, I was using Venkman only for debugging, and before that the Netscape javascript debugger (or whatever it was called) and before that.... the old "alert" methods ;-) Greetings, Laurent -- Laurent Bugnion, GalaSoft Software engineering: http://www.galasoft-LB.ch PhotoAlbum: http://www.galasoft-LB.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch Hi
I always get "This is not a valid location for a breackpoint" when ever I try to insert a break point on the aspx html code. Any ideas? thanks, Victor Show quote "Laurent Bugnion" <galasoft***@bluewin.ch> wrote in message news:euH5cGa0GHA.2516@TK2MSFTNGP06.phx.gbl... > Hi, > > Mark Rae wrote: >> <lasalsatx@newsgroups.nospam> wrote in message >> news:u9z5DET0GHA.4252@TK2MSFTNGP03.phx.gbl... >> >> >>>How can I debug javascript code on a page while the page is running? >> >> >> Use the JavaScript debugger method... >> >> E.g. >> >> <script> >> >> var strMessage="Hello"; >> debugger; >> alert(strMessage); >> >> </script> >> >> Run your app in debug mode (F5, not Ctrl-F5), and execution will stop on >> the debugger; line. > > I would rather recommend a method which doesn't need to modify the source > code: Simply put a breakpoint in the code... > > HTH, > Laurent > -- > Laurent Bugnion, GalaSoft > Software engineering: http://www.galasoft-LB.ch > PhotoAlbum: http://www.galasoft-LB.ch/pictures > Support children in Calcutta: http://www.calcutta-espoir.ch Hi,
lasalsatx@newsgroups.nospam wrote: > Hi In my experience, setting breakpoints in inline JavaScript code doesn't > > I always get "This is not a valid location for a breackpoint" when ever I > try to insert a break point on the aspx html code. Any ideas? > > thanks, > > Victor always work. The best is to place your JavaScript code in external JS files. This has many other advantages too anyway (files are cached, modularity, reusability...). HTH, Laurent -- Laurent Bugnion, GalaSoft Software engineering: http://www.galasoft-LB.ch PhotoAlbum: http://www.galasoft-LB.ch/pictures Support children in Calcutta: http://www.calcutta-espoir.ch thanks that took care of the problem.
Victor Show quote "Laurent Bugnion" <galasoft***@bluewin.ch> wrote in message news:urmC5Ff0GHA.4816@TK2MSFTNGP06.phx.gbl... > Hi, > > lasalsatx@newsgroups.nospam wrote: >> Hi >> >> I always get "This is not a valid location for a breackpoint" when ever I >> try to insert a break point on the aspx html code. Any ideas? >> >> thanks, >> >> Victor > > In my experience, setting breakpoints in inline JavaScript code doesn't > always work. The best is to place your JavaScript code in external JS > files. This has many other advantages too anyway (files are cached, > modularity, reusability...). > > HTH, > Laurent > -- > Laurent Bugnion, GalaSoft > Software engineering: http://www.galasoft-LB.ch > PhotoAlbum: http://www.galasoft-LB.ch/pictures > Support children in Calcutta: http://www.calcutta-espoir.ch JavaScript code can be debugged, but not in the same way as ASP.Net, because
it is client-side code. For debugging JavaScript, you set up Internet Explorer to allow JavaScript debugging, use the Tools|Options menu, and the Advanced tab. Uncheck the "Disable Script Debugging (Internet Explorer)" item. Then, when a bug occurs in client-side JavaScript, IE will allow you to launch a debugger to debug the script (usually Visual Studio). You can also set a break point in JavaScript by adding the following line of JavaScript where you want the debugger to break: debugger; -- Show quoteHTH, Kevin Spencer Microsoft MVP Chicken Salad Surgery What You Seek Is What You Get. "Laurent Bugnion" <galasoft***@bluewin.ch> wrote in message news:urmC5Ff0GHA.4816@TK2MSFTNGP06.phx.gbl... > Hi, > > lasalsatx@newsgroups.nospam wrote: >> Hi >> >> I always get "This is not a valid location for a breackpoint" when ever I >> try to insert a break point on the aspx html code. Any ideas? >> >> thanks, >> >> Victor > > In my experience, setting breakpoints in inline JavaScript code doesn't > always work. The best is to place your JavaScript code in external JS > files. This has many other advantages too anyway (files are cached, > modularity, reusability...). > > HTH, > Laurent > -- > Laurent Bugnion, GalaSoft > Software engineering: http://www.galasoft-LB.ch > PhotoAlbum: http://www.galasoft-LB.ch/pictures > Support children in Calcutta: http://www.calcutta-espoir.ch Hi,
Kevin Spencer wrote: > JavaScript code can be debugged, but not in the same way as ASP.Net, because True but incomplete. You can set breakpoints in client-side JavaScript > it is client-side code. For debugging JavaScript, you set up Internet > Explorer to allow JavaScript debugging, use the Tools|Options menu, and the > Advanced tab. Uncheck the "Disable Script Debugging (Internet Explorer)" > item. Then, when a bug occurs in client-side JavaScript, IE will allow you > to launch a debugger to debug the script (usually Visual Studio). You can > also set a break point in JavaScript by adding the following line of > JavaScript where you want the debugger to break: > > debugger; code using F9 and *without* modifying the code by adding the debugger statement. That would be the recommended way. Similarly, you can also attach the VS2005 debugger to a running instance of IE and debug the client-side code, even if the page is served by a remote sever. In that sense, it's very similar to ASP.NET, except that the code runs in another process. HTH, Laurent -- Laurent Bugnion, GalaSoft Software engineering: http://www.galasoft-LB.ch Private/Malaysia: http://mypage.bluewin.ch/lbugnion Support children in Calcutta: http://www.calcutta-espoir.ch <lasalsatx@newsgroups.nospam> wrote in message
news:e49Ba1e0GHA.2516@TK2MSFTNGP06.phx.gbl... What happens if you use the JavaScript debugger method...?> I always get "This is not a valid location for a breackpoint" when ever I > try to insert a break point on the aspx html code. Any ideas? In IE, tools options advanced, ensure that disable script debugging is
unchecked. in VS, debug to your page and once loaded, you can either go to debug -> windows - runing documens or use CTRL-ALT-N to bring up the script explorer, you then select the page you want to debug and then you can set breakpoints in the js and when the breakpoint is hit, step through it. -Adrian (for some reason the running docs window is missing on my VS, so I use the CTRL-ALT-N approach) <lasalsatx@newsgroups.nospam> wrote in message Show quote news:u9z5DET0GHA.4252@TK2MSFTNGP03.phx.gbl... | How can I debug javascript code on a page while the page is running? | | Thanks, | | Victor | | Hi Victor,
Besides other community member's useful input, you may also checkout following articles: #How to: Enable Client-Side Script Debugging http://msdn2.microsoft.com/en-us/library/k2h50zzs.aspx I hope this helps. Please feel free to post here if anything is unclear. Sincerely, Walter Wang (waw***@online.microsoft.com, remove 'online.') Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
|||||||||||||||||||||||