javascript 仅限 IE8 - 对象不支持属性或方法“小部件”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8728040/
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
IE8 only - Object doesn't support property or method 'widget'
提问by rickyduck
I am getting an error related to [jCoverflip][1] that only occurs in IE8. The following error occurs:
我收到与 [jCoverflip][1] 相关的错误,该错误仅发生在 IE8 中。出现以下错误:
SCRIPT438: Object doesn't support property or method 'widget' jquery.jcoverflip.js, line 508 character 1
SCRIPT438:对象不支持属性或方法“widget”jquery.jcoverflip.js,第 508 行字符 1
which relates to the following code:
这与以下代码有关:
$.widget( 'ui.jcoverflip', {
I have jQuery and jQueryUI both included, before the script, plus the script runs fine in all other browsers.
我在脚本之前包含了 jQuery 和 jQueryUI,而且脚本在所有其他浏览器中运行良好。
Whats causing the issue?
是什么导致了这个问题?
采纳答案by T.J. Crowder
You seem to be loading jquery twice:
你似乎加载了两次 jquery:
<!-- First here -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/./scripts/jquery-ui-1.7.2.custom.js"></script>
<!-- Then again here -->
<script type="text/javascript" src="/scripts/jquery.js"></script>
They appear to be v1.3.2 and v1.0.4 (!), respectively. Those are completelyout of date. I don't know what jQuery UI 1.7.2's requirements are, but I'm sure v1.0.4 won't do it. v1.3.2 might, jQuery UI 1.7.2 is a couple of years old. (You might at least look at jQuery UI 1.7.3, which saysit's for jQuery v1.3.2.)
它们似乎分别是 v1.3.2 和 v1.0.4 (!)。这些已经完全过时了。我不知道 jQuery UI 1.7.2 的要求是什么,但我确定 v1.0.4 不会这样做。v1.3.2 可能,jQuery UI 1.7.2 已经有几年了。(你至少可以看看 jQuery UI 1.7.3,它说它适用于 jQuery v1.3.2。)
Also, you're using MooTools on the page, but I don't immediately see where you're calling jQuery.noConflict()
(I didn't go digging all that deep). That could well be the problem, MooTools and jQuery both try to use $
. To avoid a conflict, immediately after loading jQuery, do this:
此外,您在页面上使用 MooTools,但我没有立即看到您在调用哪里jQuery.noConflict()
(我没有深入挖掘)。这很可能是问题所在,MooTools 和 jQuery 都尝试使用$
. 为避免冲突,在加载 jQuery 后立即执行以下操作:
<script>
jQuery.noConflict();
</script>
回答by user3323009
I had similiar problem. There is jquery.ui.widget.js which wasn't included. My problem got solved after including it.
我有类似的问题。有未包含的 jquery.ui.widget.js。包含它后我的问题就解决了。