IE 无效参数错误 - 说这是 jQuery 中的错误,但我不这么认为

发布于 2024-08-10 23:49:09 字数 764 浏览 5 评论 0原文

我正在为 IE7 中的无效参数错误而烦恼,也许是所有 IE 的...

该网站是: http: //www.karencaldwelldesign.com/fashion

IE 说这是第 12 行的错误,但如果我打开脚本调试器,它会说问题出在 jQuery 中的某些代码上。我不买那个。

所以,我查看了我的脚本(http:// www.caldwellsnyder.com/__data/assets/js_file/0003/5943/kc-gallery.js)和第 65 行似乎是问题:

data = '<div id="content'+id+'" class="content">'+data+'</div>';

数据是从 jQuery $.ajax() 函数返回的,但我需要用一个额外的编号 div 来包裹它。

特别是 id 变量导致了无效参数错误,但我不知道为什么! var 只是一个递增的数字。从该行中删除 var 可以让页面完美加载,但我确实需要以这种方式增加 id。

有谁知道为什么这个简单的变量会导致 IE 中的参数无效?

I am pulling my hairs out over an invalid argument error in IE7, maybe all IE's...

The site is: http://www.karencaldwelldesign.com/fashion

IE says it is an error on line 12, but if I open up Script Debugger it says the problem is with some code in jQuery. I don't buy that.

So, I looked at my script (http://www.caldwellsnyder.com/__data/assets/js_file/0003/5943/kc-gallery.js) and line 65 seems to be the problem:

data = '<div id="content'+id+'" class="content">'+data+'</div>';

data is returned from the jQuery $.ajax() function, but I needed to wrap it with an additional numbered div.

In particular it is the id variable that is caused the invalid argument error, but I have no idea why! The var is just a number that gets incremented. Removing the var from that line lets the page load perfectly, but I really need to increment the id in this way.

Does anyone have any idea why this simple variable would be cause invalid argument in IE?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

背叛残局 2024-08-17 23:49:09

不知何故,你最终试图设置 -5px 的宽度; IE 不喜欢这样。该值来自 JScrollPane.js 中的 $this.css(cssToApply); 行,该行通过计算变量 realPaneWidth 获取该值:

var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;

其中, paneWidth< /code> 和 settings.scrollbarWidth 都等于 676,而 settings.scrollbarMargin 为 5,即 -5(p 为零)。

kc-gallery.js 中,您似乎正在用函数 applyScroll 中的 scrollbarWidth 值 676 来初始化 jScrollPane。这是从分配给变量 check_images 的 setInterval 函数调用的,这使我们从 IE 在设置 width 时实际出错的位置一路备份调用堆栈-5px

所以这肯定与您使用 JScrollPane 的方式有关。您可能需要检查文档以获取任何提示 - 我自己从未使用过该插件,所以恐怕我无法提供帮助。但是, scrollbarWidth 值 676 似乎有点过高... 根据 JScrollPane 文档

scrollbarWidth [int] - 创建的滚动条的宽度(以像素为单位)(默认为 10)

Somehow you're ending up trying to set a width of -5px; IE doesn't like that. That value is coming from the line $this.css(cssToApply); in JScrollPane.js which gets it from calculating the variable realPaneWidth:

var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;

In that, paneWidth and settings.scrollbarWidth both equal 676, and settings.scrollbarMargin is 5, giving you -5 (p is zero).

In kc-gallery.js you appear to be initialising jScrollPane with the value of 676 for scrollbarWidth in the function applyScroll. This is called from the setInterval function assigned to the variable check_images, and that takes us all the way back up the call stack from the place where IE actually errors on setting width to -5px.

So it's definitely something to do with the way you're using JScrollPane. You may want to check the documentation for any tips - I've never used that plugin myself, so I'm afraid I can't help with that. However, a scrollbarWidth value of 676 seems a little excessive... according to the JScrollPane docs:

scrollbarWidth [int] - the width of the created scrollbar in pixels (defaults to 10)

孤千羽 2024-08-17 23:49:09

当您尝试将 DOM 属性设置为无效值时,您看到的错误来自 jQuery。例如,尝试将 z-index 设置为 NaN 或字符串。 IE 会出现此错误,而 Firefox 和其他浏览器会忽略该值。

您可以通过将以下行放入 IE8 中此页面的控制台或使用 Jash 对于早期版本: jQuery("#header").css("z-index", NaN);
看起来

你的变量 glob_index 在某些时候变得未定义,因此在尝试将 DOM 节点的 z-index 设置为此时 jQuery 会出错。

The error you are seeing comes from jQuery when you try to set a DOM attribute to a value that is invalid. For example try setting a z-index to NaN or a string. IE errors on this where firefox and other browsers just ignore the value.

You can see an example of this by dropping the following line in to the console on this page in IE8 or using Jash for earlier versions: jQuery("#header").css("z-index", NaN);

It looks like your variable glob_index is becoming undefined at some point, thus jQuery errors when trying to set the z-index of a DOM node to this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文