简体   繁体   English

调试ie7中的javascript错误?

[英]debugging javascript error in ie7?

All I get is this: 我得到的就是:

An error has occurred in the script on this page
line: 31
char: 5
error: expected identifier, string or number
code: 0
url: http://example.com

It's difficult to find that line since I have several external and internal scripts. 因为我有几个外部和内部脚本,所以很难找到该行。

How can I debug this? 我该怎么调试呢? (By the way, the scripts have no errors in chrome or firefox or ie8+) (顺便说一句,脚本在chrome或firefox或ie8 +中没有错误)

You can download IETester which lets you use various versions of IE (6-8) and has built-in developer tools. 您可以下载IETester,它允许您使用各种版本的IE(6-8)并具有内置的开发人员工具。 They're not spectacular, but they're better than the nothing that old versions of IE provide. 它们并不壮观,但它们比旧版IE提供的功能更好。

If it says it's on the page, then it means the page itself. 如果它说它在页面上,则表示页面本身。 If it was in an external file, it would indicate that the error occured in something.js . 如果它在外部文件中,则表示在something.js发生了错误。

Open up your webpage, right click on the page and select "View Source". 打开您的网页,右键单击页面并选择“查看源代码”。 Go to line 31 and try and see what's wrong with it. 转到第31行,试着看看它有什么问题。

Try debugging it with IE8's Developer Tools (press F12). 尝试使用IE8的开发人员工具进行调试(按F12)。 You should be able to step through the JS code (from all your scripts) to find out what is wrong with line 31 / char 5. 您应该能够逐步执行JS代码(来自所有脚本)以找出第31行/第5行的错误。

You can also enable debugging for IE at 您还可以在以下位置启用IE的调试功能

(Tools -> Options -> (uncheck) Disable script debugging (Internet Explorer).  

After you disable it, IE will prompt you to debug when error occurs. 禁用它后,IE将提示您在发生错误时进行调试。 Then you can debug with VS or MS script Editor. 然后,您可以使用VS或MS脚本编辑器进行调试。

I got the same issue when try to to figure out what 's wrong with the code on IE7, after spending hours research and trying many different solutions, finally, the following two bars are great tools for me: 当我花了几个小时的时间研究并尝试了许多不同的解决方案时,我试图找出IE7上的代码有什么问题时遇到了同样的问题,最后,以下两个栏对我来说都是很好的工具:

1) http://www.debugbar.com/ 1) http://www.debugbar.com/

provide a convenience UI to with feature like source, style, DOM, Script, HTML check. 通过源,样式,DOM,脚本,HTML检查等功能提供方便的UI。

2) http://www.my-debugbar.com/wiki/CompanionJS/Installing 2) http://www.my-debugbar.com/wiki/CompanionJS/Installing

The main advantage of this is providing a console for IE6 or IE7, so you can see what are the error (in the console log) 这样做的主要优点是为IE6或IE7提供了一个控制台,因此您可以看到错误是什么(在控制台日志中)

  • Note: 注意:
  • they are both free 他们都是自由的
  • screen shot of both two toolbars 两个工具栏的屏幕截图

在此输入图像描述

Use Firefox with Firebug. 将Firefox与Firebug一起使用。 Look at every external script around the line number mentioned in the error dialog. 查看错误对话框中提到的行号周围的每个外部脚本。 Trailing commas every time! 每次尾随逗号!

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

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