Using Visual Studio to Debug JavaScript in IE
来源:互联网 发布:大学网络宣传部简介 编辑:程序博客网 时间:2024/04/29 03:10
Using Visual Studio to Debug JavaScript in IE
Introduction
Anyone who has done some work with JavaScript knows it can be very frustrating. Often you have to use:Alert("I am here");
type of code to debug it. Visual Studio and IE (Internet Explorer) have the ability to debug JavaScript code, including setting break points in your JavaScript.
Background
When I started working in .NET, I was a VB.NET Windows programmer. When I started to use ASP.NET, the need to use JavaScript started to come up. It was easy for me to make mistakes in my JavaScript since it is a C based language, so there was a real need to have the ability to debug my JavaScript code. I don't think I would have ever ventured into the JavaScript world without being able to debug it in Visual Studio.
Setup
In IE you have to enable script debugging. Go to Tools, then Internet Options. Click on the Advanced Tab. Un-check disable script debugging (Internet Explorer). It is checked by default.
NOTE: you will find with script debugging enabled that many Internet sites have lots of JavaScript problems. So I would suggest only turning this on when you want to debug your JavaScript otherwise you will be bothered by IE asking you if you want to debug other peoples bad JavaScript.
Once you have this set, a new option is available in your View menu. If you click on View there is now a script debugger option. If you are using IE 7 you will need to click on Tools, then Menu bar to see the View menu item.
So at this point in Visual Studio, if you set your web project / web site to debug mode and run it, you can debug your JavaScript.
Under View/Script Debugger there are two options. The first is Open.
This will open the HTML/JavaScript in Visual Studio and allow you to set break points in your JavaScript.
The other option is Break at next statement which does just what it says. When the next JavaScript gets run, you will go into Visual Studio and it will break on the first JavaScript line.
Once you are in the Visual Studio debugger, you can use all of the normal tools you have to investigate variables etc. to help with the debugging of the JavaScript code.
Conclusion
I have found that being able to debug my JavaScript has really helped me to find all the small problems and bugs that are so easy to create when writing JavaScript code.
I hope this article helps you in your JavaScript debugging.
- Using Visual Studio to Debug JavaScript in IE
- Using Visual Studio to Debug JavaScript in IE
- How to debug a Visual Studio .NET 2005 Add-In
- Using #region Directive With JavaScript Files in Visual Studio 【转载】
- Using #region Directive With JavaScript Files in Visual Studio
- Using the JavaScript console in Visual Studio Code
- Using GDB in Visual Studio
- Remote debug using Visual Studio 2005
- How to change the default browser to debug with in Visual Studio 2008?
- Using LINQ in Visual Studio 2005
- Using Database Features in Visual Studio
- 3 way to debug via Visual Studio
- Using Aptana To Edit/Debug Javascript
- Debugging JavaScript in Visual Studio
- Debug JavaScript in JSP or PHP Pages with Visual Studio 2008
- IE F12 debug using
- How to compile PortAudio in Visual Studio
- Connect to localdb in Visual Studio 2015
- 通用权限管理设计 之 数据库结构设计
- Python--集合
- FFMPEG学习----打印视频信息
- 从LongAdder看更高效的无锁实现
- 破解Idea 16注册机
- Using Visual Studio to Debug JavaScript in IE
- mariadb多源复制中只同步1个库
- 故障案例--mysql如何定位执行完但未提交的事务内容
- 栈2--链栈
- hdu 4027(线段树区间开方求和)
- 02-swift微博自定义log
- 工厂模式
- Node.js exports 和 require 两个对象
- hdu 1527 取石子游戏 (威佐夫博奕)