javascript - Is there any way to force Internet Explorer to break on alert()? - Stack Overflow

I'm trying to debug an error message in a large and plicated frames based webASP.Net app using IE

I'm trying to debug an error message in a large and plicated frames based web/ASP.Net app using IE8 and Visual Studio 2010. Specifically, I am getting a "Member not found" message box which appears to be a straightforward JavaScript alert(). Unfortunately I don't know where in the code the problem is happening, and fiddler2 wasn't much help in this case.

My question is, can I get IE to break at the alert() call so that I can debug it?

I'm trying to debug an error message in a large and plicated frames based web/ASP.Net app using IE8 and Visual Studio 2010. Specifically, I am getting a "Member not found" message box which appears to be a straightforward JavaScript alert(). Unfortunately I don't know where in the code the problem is happening, and fiddler2 wasn't much help in this case.

My question is, can I get IE to break at the alert() call so that I can debug it?

Share Improve this question edited Aug 22, 2019 at 13:15 Stephen Kennedy asked Jul 1, 2011 at 16:12 Stephen KennedyStephen Kennedy 21.6k24 gold badges97 silver badges113 bronze badges
Add a ment  | 

6 Answers 6

Reset to default 5

String search for "Member not found"

Add 1 / 0; before the line.

Turn on break on all errors.

(I assumed you knew the developer tool existed. Hit F12 and navigate to the script tab)

Edit:

Thanks to @DmitriyNaumov

var aalert = window.alert;
window.alert = function() {
  aalert.apply(this, arguments);
  1 / 0;
}

You can try using the IE Developer Toolbar from Microsoft. I don't know if it allows you to Set JS breakpoints, but it is a great tool to have on hand anyway!

You can use the IE debugger , press F12 and then under the script tab you can add breakpoints

Using IE 8 you can use Developer Tools which is a little like Firebug for Mozilla Firefox.

http://www.microsoft./download/en/details.aspx?id=18359

(for more information)

this way you can create breakpoints and debug the script execution on the page step by step

Just press F12

Change alert into a new function that throws a proper error.

window.alert = function(msg) {
  throw "Alert: " + msg;
};

Older versions of IE don't allow overwriting window properties like alert in this way in JavaScript ... but you can still do it with VBScript.

Sub alert(msg)
  Err.Raise 8, "Alert", msg
End Sub

If you go the VBScript route, make sure it precedes any JavaScript that references the alert function, or you'll have missed your opportunity.

If it's a window.alert, you can do this:

  1. Enable external debuggers in IE.
  2. Attach visual studio as a script debugger.
  3. Reproduce the problem.
  4. While the alert box is shown, break in the debugger.
  5. When you dismiss the alert, the debugger will be paused on the next line of code.
  6. Use the current call stack to set a breakpoint where ever before the call will be most useful for the next time.

Unfortunately this trick only applies to alert and confirm, since they are modal dialogs.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744370711a4570935.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信