Javascript错误行号 [英] Javascript Error Line Numbers

查看:96
本文介绍了Javascript错误行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大量javascript代码的jsp。每当页面上出现javascript错误(IE浏览器的状态栏中显示)时,报告包含错误的行号与实际包含错误的行号不匹配。
我正在右键点击>查看来源以查找报告的行号。但该行不包含错误。我想,错误在于其他一些方面。
可能是报告错误行号的原因。

I have a jsp with lots of javascript code. Whenever there is a javascript error on the page, shown in the status bar of the IE browser, the line number reported to contain the error, does not match with the line number that actually contains the error. I am doing a right click>view source to find the line number reported. But that line does not contain the error. The error, I assume, is in some other line. What could be the reason for the erroneous line numbers being reported.

请帮助。

推荐答案

经过大量试验,我发现了这个问题。希望这对面临这个令人沮丧的问题的一些人有用。

I found the problem after a lot of trials. Hopefully, this will be of use to some guys facing this frustrating problem.

RightClick> View Source是浏览器看到呈现页面的代码。然而,这还不是全部。该页面还可能有其他对css ans js文件的HTTP请求。这就是我的情况。错误是在导入的( NOT INCLUDED ;如果包含错误将在代码上)js文件中。并且报告的行号与该js文件相关。

RightClick>View Source is the code what the browser sees to render the page. However, that is not all. The page could also have other HTTP requests to css ans js files. That was what was happening in my case. The error was in an imported(NOT INCLUDED ; had it been included the error would have been on the code) js file. And the line number reported was relative to that js file .

然而,回想起来,我发现这是正确的,因为导入的文件是单独存储在浏览器缓存中的,因为它们是对Web服务器的独立HTTP请求。因此不应出现在RightClick>查看源代码中。

In retrospect ,however, i find this to be correct, since the imported files are stored separately in the browser cache, as they are independent HTTP requests to the web server. And hence should not appear in the RightClick>View Source code.

可能的问题:
但是,尽管在我的情况下该行报告的单个js文件中的数字被发现是正确的,这可能并非总是如此。
在大多数企业应用程序中,js和css经常被缩小以减少字节占用空间。因此,您在IDE中可能正在查看的js文件将与浏览器看到的不同。因此,行号可能不同。行号将是浏览器看到的文件的压缩版本。

POTENTIAL PROBLEM: However, though in my case the line number in the individual js file,reported, was found to be correct, that may not always be true. In most enterprise applications, js and css es are often minified to reduce the byte footprint. Hence the js file that you may be looking at , in your IDE, will not be the same as the browser sees. Hence the line numbers could then be different. The line numbers will be w.r.t the compressed version of the file that the browser sees.

IE JAVASCRIPT调试:
我发现这个页面,它承诺在IE环境中提供调试器环境(尽管不复杂)。

IE JAVASCRIPT DEBUGGING: I found this page , which promises to offer debugger environment(albeit ,not sophisticated) in the IE environment.

http://jonathanboutelle.com/2006/01/16/how-to-debug-javascript-in-internet -explorer /
我没试过,因为我没有安装完整的Office软件包。

http://jonathanboutelle.com/2006/01/16/how-to-debug-javascript-in-internet-explorer/ I didnt try it, as I dont have the complete Office package installed.

这篇关于Javascript错误行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆