G
Guest
How can I debug javascript code on a page while the page is running?
Thanks,
Victor
Thanks,
Victor
How can I debug javascript code on a page while the page is running?
Mark said: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...
Mark said: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...?
![]()
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
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?
Laurent Bugnion said:Hi,
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
Kevin said: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;