Error with jQuery (in IE8)

一个人想着一个人 提交于 2020-01-15 12:39:09

问题


I get an error when I use:

$(document).ready(function() {
    $("#single_image").fancybox();
})

the error is: object doesn't support this property or method

I tried to remove the ; but I still get the error!

I'm using this plugin: http://fancybox.net/


回答1:


The error given indicates that the fancybox is not known, this seems to suggest it did not load the fancybox-js file.

If this works in other browsers, i am a bit baffled as to why that could be.

[EDIT: after further googling] Apparently this is a known problem: which version of fancybox/jquery are you using? You need to be using at least version 1.4.2 of jquery in conjunction with version 1.3.1 of fancybox.

This might be old, since jquery is now at 1.5.1 and fancybox 1.3.4 But maybe this is something to investigate further: a mismatch in versions?




回答2:


Fixed: I was having the same problem using fancybox,

When I added parameter 'type': 'iframe' it started working fine in IE

Although after adding this, the it stopped autoresizing, you can work around by adding 'height' and 'width' parameters.

HTH, Jack.




回答3:


When you import the Fancybox JQuery plugin you must use './' like this:

<script type="text/javascript" src="./fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" href="./fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />



来源:https://stackoverflow.com/questions/5139733/error-with-jquery-in-ie8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!