Fancybox不适用于jQuery v1.9.0 [f.browser未定义/无法读取属性'msie'] [英] Fancybox doesn't work with jQuery v1.9.0 [ f.browser is undefined / Cannot read property 'msie' ]

查看:93
本文介绍了Fancybox不适用于jQuery v1.9.0 [f.browser未定义/无法读取属性'msie']的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fancybox打破了新的jQuery v1.9.0.

Fancybox breaks with the new jQuery v1.9.0.

它同时影响Fancybox v1.3.4和更低版本-和-v2.1.3和更低版本.

显示的错误是:

v1.3.4:

Timestamp: 15/01/2013 10:03:28 AM
Error: TypeError: b.browser is undefined
Source File: ...fancybox/jquery.fancybox-1.3.4.pack.js
Line: 18

...其他错误

Uncaught TypeError: Cannot read property 'msie' of undefined jquery.fancybox-1.3.4.pack.js:18
Uncaught TypeError: Object [object Object] has no method 'fancybox'

在2.1.3版中:

Timestamp: 15/01/2013 10:09:58 AM
Error: TypeError: $.browser is undefined
Source File: h.../fancybox2.1.3/jquery.fancybox.js
Line: 139

如果您使用它来调用jQuery:

If you are using this to call jQuery :

<script src="http://code.jquery.com/jquery-latest.js"></script>

... 任何现有的fancybox实施都会失败!

推荐答案

似乎在jQuery中存在一个错误,报告在这里:

It seems like it exists a bug in jQuery reported here : http://bugs.jquery.com/ticket/13183 that breaks the Fancybox script.

还要检查 https://github.com/fancyapps/fancyBox/issues/485 供进一步参考.

Also check https://github.com/fancyapps/fancyBox/issues/485 for further reference.

作为一种解决方法,回滚到 jQuery v1.8.3 ,要么修复了jQuery错误,要么修复了Fancybox.

As a workaround, rollback to jQuery v1.8.3 while either the jQuery bug is fixed or Fancybox is patched.

更新(2013年1月16日):Fancybox v2. 1.4 已发布,现在可以在jQuery v1.9.0中正常使用.

UPDATE (Jan 16, 2013): Fancybox v2.1.4 has been released and now it works fine with jQuery v1.9.0.

对于fancybox v1.3.4-,您仍然需要回滚到 jQuery v1.8.3 或应用 迁移脚本 ,如@Manu的答案所指出.

更新(2013年1月17日): Fancybox v1.3.4 用户的解决方法:

UPDATE (Jan 17, 2013): Workaround for users of Fancybox v1.3.4 :

修补 fancybox js文件 使其与jQuery v1.9.0兼容,如下所示:

Patch the fancybox js file to make it work with jQuery v1.9.0 as follow :

  1. 使用文本/html编辑器打开 jquery.fancybox-1.3.4.js 文件(完整版,非压缩版).
  2. 在第29行发现:

  1. Open the jquery.fancybox-1.3.4.js file (full version, not pack version) with a text/html editor.
  2. Find around the line 29 where it says :

isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

,然后将其替换为(编辑,2013年3月19日:更准确的过滤器):

and replace it by (EDITED March 19, 2013: more accurate filter):

isIE6 = navigator.userAgent.match(/msie [6]/i) && !window.XMLHttpRequest,

更新(2013年3月19日):同样,在615行附近用navigator.userAgent.match(/msie [6]/i)替换$.browser.msie(和/或替换所有$.browser.msie实例,如果有的话),谢谢joofow ...就是这样!

UPDATE (March 19, 2013): Also replace $.browser.msie by navigator.userAgent.match(/msie [6]/i) around line 615 (and/or replace all $.browser.msie instances, if any), thanks joofow ... that's it!

或从以下位置下载已修补的版本 这里 (已于2013年3月19日更新...感谢 fairylee 指出了额外的结案时间括号)

Or download the already patched version from HERE (UPDATED March 19, 2013 ... thanks fairylee for pointing out the extra closing bracket)

注意:这是一个非官方的补丁程序,Fancybox的作者不支持该补丁程序,但是它照常工作.您可以自担风险使用它;)

NOTE: this is an unofficial patch and is unsupported by Fancybox's author, however it works as is. You may use it at your own risk ;)

(可选)您可能希望回滚到 jQuery v1.8.3 或应用 迁移脚本 如@Manu的答案所指出.

Optionally, you may rather rollback to jQuery v1.8.3 or apply the migration script as pointed out by @Manu's answer.

这篇关于Fancybox不适用于jQuery v1.9.0 [f.browser未定义/无法读取属性'msie']的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆