Debug IE中的JavaScript

來源:互聯網
上載者:User

預設的script debugging是被關閉的, 要開啟需要:

Tools->Internet Options…->Advanced->Disable Script Debugging

 

在XP SP2上, 選項被拆分成了兩項:

Tools->Internet Options…->Advanced->Disable Script Debugging (Internet Explorer)
Tools->Internet Options…->Advanced->Disable Script Debugging (Other)

 

當你開啟了Script Debugging之後, 功能表項目‘View->Script Debugger’會變的可見, 使用它你就可以斷入debugger中了.

 

一般使用的debugger有三種, 第一個是Visual Studio, 第二個是Microsoft Script Debugger, 第三個是Microsoft Script Editor.

 

簡單說一下Visual Studio中的script debugging.

第一種方法: 比如說有一個包含JavaScript的html的頁面.

  • Enable script debugging in IE (see image: Tools -> Internet Options -> Advanced)
  • Open the html file in Visual Studio
  • Set a breakpoint and hit F5 / Start Debugging or hit F10 / F11 to single step

剩下的就跟在debugging一個普通程式一樣了.

 

第二種方法: 如果應用程式不可能通過在visual Studio中點擊F5來啟動, 比如說開始debug之前指令碼還在伺服器上, 那麼就需要用第二種方式了.

  • Open the web site in Visual Studio and open the .js file for editing
  • Set a breakpoint at a suitable place in the .js file (eg in the this.initialize function)
  • In Visual Studio go to Debug -> Attach to Process
  • Ensure that either Automatic or Script is selected as the type of code to debug (see images below)
  • Select the relevant IE process from the available process and click "Attach" (see image below)
  • Return to IE and load up the gadet (or reload it) and the breakpoint should fire and you'll drop back into Visual Studio as before

唯一不爽的地方就是你需要經常在"Attach to Process"對話方塊中進進出出. 相比起Visual Studio的強大功能來說, 這個缺點也算不得什麼.

 

如果你希望在Visual Studio中新開一個瀏覽器, 你可以在solution Explorer中選擇一個頁面, 按右鍵, 選擇"Browse With". 這裡你還能更改預設的瀏覽器.

 

原文:

Script Debugging with Visual Studio

http://blogs.msdn.com/mikeormond/archive/2006/01/13/512496.aspx

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.