javascript 如何解决错误:“未定义为空或不是对象,即在 ext js 中”在 IE 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6109172/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 19:30:31  来源:igfitidea点击:

How to solve error: "undefined is null or not object ie in ext js" in IE?

javascriptextjs

提问by Angelin Nadar

I think its the cause of trailing comma, or syntax error, variable used without declaration. My js fiel is 1000 lines od code. Since the error is not provding me the line no. Its becoming dfficult to debug. Please help me with debugging techniques for IE. The script works very well with Firefox, Safari.

我认为这是尾随逗号或语法错误的原因,未声明就使用了变量。我的 js 字段是 1000 行 od 代码。由于错误没有向我证明行号。它变得难以调试。请帮助我调试 IE 技术。该脚本适用于 Firefox、Safari。

采纳答案by wombleton

I'd jslintthe file. That will find the issue as well as any others you may have.

我会jslint文件。这将找到问题以及您可能遇到的任何其他问题。

You can run it as a command line utility via node.

您可以通过 node将其作为命令行实用程序运行。

回答by Johan Olsson

include this <script type="text/javascript" src="https://getfirebug.com/firebug-lite-debug.js"></script>and <html debug="true">will give you an firebug console
http://getfirebug.com/firebuglite#Debug

包括这个<script type="text/javascript" src="https://getfirebug.com/firebug-lite-debug.js"></script><html debug="true">会给你一个萤火虫控制台
http://getfirebug.com/firebuglite#Debug

回答by Chau

If you are developing through Microsoft Visual StudioI remember it will help you find trailing commas by highlighting the following }element with a green curly underline.

如果您是通过Microsoft Visual Studio进行开发,我记得它会通过}用绿色卷曲下划线突出显示以下元素来帮助您找到尾随逗号。

If you use the built-in developer toolsin IE8and later, you can step through your code in the browser and determine which line causes the error - starting from the top.

如果使用内置的开发者工具IE8和更高版本,可以通过在浏览器代码步骤,并确定哪些行导致错误-从顶部开始。

If you are not using any debugging tools in IE, then I will advise you to - just like Johanand bjorndare suggesting.

如果您没有在IE 中使用任何调试工具,那么我会建议您 - 就像Johanbjornd所建议的那样。

Happy hunting :)

狩猎快乐:)

回答by bjornd

For debugging in IE I would recommend you install DebugBar. This extension is similar to FireBug for Firefox.

为了在 IE 中进行调试,我建议您安装DebugBar。此扩展类似于 Firefox 的 FireBug。

回答by MMT

If you are using eclipse :

如果您使用的是日食:

configure spketplug-in editor for java script

为java脚本配置spket插件编辑器

It will highlight the missing/incomplete syntax (e.g comma/semicolon)

它将突出显示缺失/不完整的语法(例如逗号/分号)

so you don't need to debug for syntax errors

所以你不需要调试语法错误

回答by Angelin Nadar

Guys, I finally did it ? I took the strength of all your techniques.

伙计们,我终于做到了吗?我利用了你所有技术的力量。

1) I put the code in a single try{ code } and catch(e) { alert('Final Err: '+ e.description); }

1) 我把代码放在一个 try{ code } 和 catch(e) { alert('Final Err: '+ e.description); }

and kept initial 200 lines uncommented and the rest commented and ran the file

并保留最初的 200 行未注释,其余的注释并运行文件

while(EOF) {
  if(got an alert of error)
    checked for trailing commas & putting missed semicolons till end.
  else
     adding some more lines later uncommented out of the commented and ran the file.
}

Finally, the page got succesfully loaded !!!

终于,页面加载成功了!!!

回答by BuzzWasHere

I had this issue using the Extjs RowExpander user extension. The issue only occurred in IE. I was able to fix it by adding a few lines of code at the top of the 'toggleRow' method:

我在使用 Extjs RowExpander 用户扩展时遇到了这个问题。该问题仅发生在 IE 中。我能够通过在“toggleRow”方法的顶部添加几行代码来修复它:

if (!this.view) {
    this.bindView();
}

For some reason IE occasionally chokes on references to 'this.view' (likely a timing issue). Running 'bindview()' ensures that 'this.view' resolves appropriately.

出于某种原因,IE 偶尔会因引用“this.view”而窒息(可能是时间问题)。运行“bindview()”可确保“this.view”正确解析。