javascript - 如何修复 Internet Explorer 8 中的 `Internet Argument Code: 0`?

标签 javascript internet-explorer

我的 JS 文件中有这一行

while(this.c.offsetWidth > this.w - s && --exit){
   w = isNaN(this.cw[0])? this.w - s : --this.cw[0];
   if(w < 1 || this.w < Math.max(1, s)){break;}
   this.c.style.width = isNaN(this.cw[0])? this.w - s + 'px' : --this.cw[0] + this.cw[1];
  }

IE 不断告诉我无效参数代码:0

但它在其他浏览器上运行良好(正如 IE 所期望的那样)

最佳答案

我的猜测是问题出在这一行:

this.c.style.width =
    isNaN(this.cw[0]) ? this.w - s + 'px' : --this.cw[0] + this.cw[1];

如果您仔细考虑 this.c.style.width 设置的内容,您会发现它将设置为不同的结果。确切地说,在前者中您使用 'px' 但在后者中则不使用。显然,其中一个是正确的,另一个是错误的......

Here is another example结尾字符是问题所在。

关于javascript - 如何修复 Internet Explorer 8 中的 `Internet Argument Code: 0`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9749112/

相关文章:

javascript - return 语句中两种不同的括号语法

javascript - HTML5 Canvas ,防手掌误触

html - Internet Explorer CSS - 中心 Div

windows - 在 Windows 上,当我的子窗口的 z 顺序相对于其 sibling 之一发生变化时,它是否应该获得 WM_WINDOWPOSCHANGED?

javascript - 从事件处理程序返回值到javascript的父函数

javascript - React SSR 闪烁页面

javascript - 关于 jQuery 模式的问题

html - IE7 内容低于容器

javascript - IE 滚动条错误

jQuery:边距动画适用于 Chrome,不适用于 Firefox 和 IE