简体   繁体   English

你如何调试这样的IE和jQuery错误

[英]How do you debug IE & jQuery errors like this

I'm developing in Javascript for quite a long time now. 我正在用Javascript开发很长一段时间了。 Usually when I hit an error in IE I know roughly where it originated even if the message received from IE is useless bunch of text. 通常当我在IE中遇到错误时,我大致知道它来自哪里,即使从IE收到的消息是无用的一堆文本。 When I don't know where the error originated, I usually try to "delete" parts of my code, until the error doesn't repeat itself, and that start manually checking line by line until I find the error. 当我不知道错误发生在哪里时,我通常会尝试“删除”我的代码的一部分,直到错误不重复,并开始逐行手动检查,直到找到错误。

I'm sure that it's far from the best approach, so I'd like to ask you how you debug error like these: 我确信这远不是最好的方法,所以我想问你如何调试这样的错误: 网页错误 -  Internet Explorer

If you are using IE8+, you can press F12 on a page to open the Developers Tools. 如果您使用的是IE8 +,则可以在页面上按F12打开开发人员工具。

This contains a JavaScript debugger, much like Firebug & Chrome Dev Tools 这包含一个JavaScript调试器,很像Firebug和Chrome Dev Tools

EDIT: In response to the comment under the question, if IE is throwing a cryptic error that you are unsure of, there is a couple of steps I would do. 编辑:在回答问题的评论时,如果IE抛出一​​个你不确定的神秘错误,我会做几个步骤。

  • Is it an IE only error? 这是IE唯一的错误吗? Does the same error occur in Firefox? Firefox中是否会出现同样的错误? Chrome? 铬?
  • Is the error occurring in a 3rd party library. 是否在第三方库中发生错误。 If you believe it is, use an un-minified version of the library. 如果您相信它,请使用该库的未缩小版本。
  • Can you replicate the error outside of your website? 你能在你的网站之外复制错误吗? Can you make the error occur in a http://jsfiddle.net/ for instance? 例如,您可以在http://jsfiddle.net/中发生错误吗?
  • If you still can't narrow down the issue, post a question on SO with your code, any error messages, and expectations of the result. 如果您仍然无法缩小问题范围,请使用您的代码,任何错误消息和结果预期在SO上发布问题。

HTH HTH

Try using non-minified version of jQuery - it will give you a better idea where exactly the error is. 尝试使用非缩小版的jQu​​ery - 它会让你更好地了解错误的确切位置。 Also, if you use VS 2010 to debug your js code in IE, it will break at the error line. 此外,如果您使用VS 2010在IE中调试您的js代码,它将在错误行中中断。 This always works fine for me. 这对我来说总是很好。

IE is the only browser that I've managed to successfully use the fantastic Visual Studio script debugger with - in my experience Visual Studio is hands down the best script debugger out there, so quite often I find myself in the reverse situation to you (running broken scripts in IE just so I can use the script debugger) IE是唯一能够成功使用梦幻般的Visual Studio脚本调试器的浏览器 - 根据我的经验,Visual Studio是最好的脚本调试器,所以我常常发现自己处于相反的状态(运行)在IE中破坏脚本只是为了我可以使用脚本调试器)

See How to debug JavaScript in Internet Explorer for instructions on how to use Visual Studio Express to debug scripts in IE - if you own a full edition of Visual Studio then its much simpler (just attach to IE as normal). 有关如何使用Visual Studio Express在IE中调试脚本的说明,请参阅如何在Internet Explorer中调试JavaScript - 如果您拥有Visual Studio的完整版本,则更简单(只需正常连接到IE)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM