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' ]

查看:14
本文介绍了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'

在 v2.1.3 中:

In v2.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 中报告了一个错误:http://bugs.jquery.com/ticket/13183 打破了 Fancybox 脚本.

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 日):同时将 $.browser.msie 替换为 navigator.userAgent.match(/msie [6]/i) 在第 615 行附近(和/或替换所有 $.browser.msie 实例,如果有的话),感谢 乔夫...就是这样!

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天全站免登陆