简体   繁体   English

IE8中的Javascript错误:未实现

[英]Javascript error in IE8: Not implemented

This one really puzzles me, as the code looks completely harmless. 这个问题让我很困惑,因为代码看起来完全无害。

IE8 halts script execution with a message: IE8通过以下消息暂停脚本执行:

Not implemented. 未实现。 map.js line:66 char:5 map.js行:66 char:5

Here is a snip from the code: 这是代码中的一个片段:

63 if(data.map[x] !== undefined && data.map[x][y] !== undefined) {
64              
65   left = (x - data.dim.x_min)*32 + 30;
66   top = (data.dim.y_max - y)*32 + 30;
67
68  /* do stuff */
XX }

debug info: x:263 data.dim.x_min:263 y:172 data.dim.y_max:174 debug info:x:263 data.dim.x_min:263 y:172 data.dim.y_max:174

Data is object returned from JQuery Ajax call. 数据是从JQuery Ajax调用返回的对象。 This works in Firefox 3.0 and 3.5, safari 4.0.2 and I've only found this error when viewing the page in IE8. 这适用于Firefox 3.0和3.5,safari 4.0.2,我在IE8中查看页面时才发现此错误。 Forcing IE8 into IE7 mode does not make the error go away. 强制IE8进入IE7模式不会使错误消失。

I don't have IE7 to debug with, but I got a tester saying that it doesn't work in IE7 either. 我没有IE7来调试,但我有一个测试人员说它在IE7中也不起作用。

The variable 'top' used in the code is an object of type DispHTMLWindow2 (outermost window object) and already in use by the browsers and that is causing the conflict, as that object cant be the target of the assignment operation. 代码中使用的变量“top”是DispHTMLWindow2(最外层窗口对象)类型的对象,并且已经被浏览器使用并且导致冲突,因为该对象不能成为赋值操作的目标。 It seems that Firefox and Safari ignore this, while IE does not allow scripts to overwrite this. Firefox和Safari似乎忽略了这一点,而IE不允许脚本覆盖它。

Solutions for this: 解决方案:

1) Declare top you are using as local variable to define it's scope where it is used. 1)声明top您使用的是局部变量来定义它的使用范围。

2) Rename the variable to something that doesn't conflict with this predefined global. 2)将变量重命名为与此预定义全局不冲突的内容。

Description of other variable names you shouldn't use 您不应使用的其他变量名称的描述

IE 8 has a great javascript debugger. IE 8有一个很棒的javascript调试器。 You might want to add a breakpoint somewhere before the error and step through the code to see if something is strange with the data. 您可能希望在错误之前的某处添加断点,并逐步执行代码以查看数据是否有异常。 IE8 is picky with trailing commas in lists which might be why you only get the error in it. IE8在列表中使用尾随逗号是挑剔的,这可能就是为什么你只能在其中得到错误。 You can pull the debugger up with F12, click Script and choose start debugging. 您可以使用F12启动调试器,单击脚本并选择开始调试。 You can add a break point by clicking on the margin where the line numbers are. 您可以通过单击行号所在的边距来添加断点。

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

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