Internet Explorer产生错误的错误行号 [英] Internet Explorer producing wrong line number for error

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

问题描述

我有一个包含大量JavaScript代码的jsp.每当IE浏览器状态栏中显示的页面上出现javascript错误时,报告包含该错误的行号就会与实际包含该错误的行号不匹配. 我正在右键单击>查看源以找到报告的行号.但是该行不包含错误.我认为该错误是在另一行中. 报错行号的原因可能是什么.

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>查看源代码是浏览器看到的呈现页面的代码.但是,这还不是全部.该页面还可能具有对css ans js文件的其他HTTP请求.这就是我的情况.该错误在导入的(未包括;如果包含该错误,则该错误将在代码中)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 es最小化以减少字节占用空间.因此,您在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.

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

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