Debug JavaScript on a remote site using Visual Stu

2019-05-23 15:24发布

问题:

I would like to debug JavaScript that resides on a 3rd-party site, using IE7 and Visual Studio 2008.

How can I break into the debugger? There are no JavaScript errors and I don't have access to the JavaScript source (since it is on a third-party site). I just want to walk through the JavaScript and see how it's working.

The JavaScript on the page I'm debugging redirects immediately.

Please note - I am debugging a JavaScript problem that is IE7-only, so I can't use Firefox/FireBug in this case.

回答1:

using vs web developer express i created a project for the URL first. the list of steps i used follow.
only diff for your case i think would be instead of F5, choose from the menu "debug -> step into" and you'll enter the debugger straight away.

  • file > new web site...
  • use the 'empty web site' template, with location being the filesystem, and just leave the filename as the default which should be in your 'my documents' dir inside the newly created dir for 'visual studio 2008'.
  • then on the right panel for 'solution explorer' right click on the dir entry and choose 'browse with...'.
  • choose internet explorer in the list and 'set as default' (this will only mean the 'solution' will use IE as the default, not the OS).
  • click cancel coz you don't wanna do anything yet (if you browse it'll open a kind of cover page in your OS default browser).
  • right click again on the dir entry and click 'start options'.
  • choose 'start URL' and put in the address of the website you wanna debug. click OK to finish.
  • then in the menu click the 'start debugging' icon, or in the menu under debug, or F5.
  • if this is the first time then says it needs to make a 'web.config' file in which debugging is enabled. just create a new one, no prob.
  • IE will open on your URL in debug mode.


回答2:

Why don't you try using IE's Developer Toolbar? It has a few features that are similar to Firebug.



回答3:

I was using the free VS Express Edition, but I guess it is the same here.

  • You open a local page in VS and launch the debugger(The play button/F5).

  • When IE appears in front of you, type in the address bar the url of the remote site you want to debug.

  • When the page is loaded, type: javascript:debugger in the address bar

  • You will arrive to an empty page(with only "debugger" in it) back in VS. All the resources available, your page and its JS files are now in the Solution Explorer. Double click the one you want to open.

  • Add your break-points in the relevant files, press continue/F5

  • The browser should come back in front.

  • Refresh the page, and if all is ok, your first breakpoint should be hit

...and now the real fun begin ;)



回答4:

IE8's dev tools are powerful enough to debug JS. Quite like Firebug, but smaller.