我的步驟是這樣的:
①、打開IE的“Internet選項”,切換到“高級”欄。
②、在"瀏覽"分類中查找兩個選項“禁用腳本調試(Internet Explorer)”和“顯示每個腳本錯誤的通知”,保證“禁用腳本調試(Internet Explorer)”處於未選狀態,“顯示每個腳本錯誤的通知”處於選中狀態。具體設置參見圖1
③、在你要調試的JavaScript代碼塊前,添加命令行debugger;
<script type="text/javascript">
function login()
{
debugger;
if (document.getElementById('user').value == '1')
{
window.location.href = 'index/index_zc.html';
}
else
{
window.location.href = 'index/index_zs.html'
}
}
</script>
按照上述步驟設置後,你再編譯運行程序,VS2005會在設置debugger處中斷等待處理,第一次設置時根據你機器的配置情況,比如你有多個Visual Studio版本都可以用來調試,會彈出圖2讓你選擇用哪個Visual Studio版本進行調試,這裏選擇VS2005,然後你就可以按F10逐行調試JavaScript代碼,你也可以利用命令窗口和監視窗口來觀察你感興趣內容,就這麼三步,相當簡單!