Fancybox没有';无法使用jQuery v1.9.0[f.browser未定义/无法读取属性';msie';]
Fancybox在新的jQuery v1.9.0中崩溃 它同时影响Fancybox v1.3.4及以下版本和-v2.1.3及以下版本。 显示的错误有: v1.3.4:Fancybox没有';无法使用jQuery v1.9.0[f.browser未定义/无法读取属性';msie';],jquery,fancybox,fancybox-2,Jquery,Fancybox,Fancybox 2,Fancybox在新的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
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中:
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:
<script src="http://code.jquery.com/jquery-latest.js"></script>
任何现有fancybox实现都将失败这里报告的jQuery中似乎存在一个bug:破坏了Fancybox脚本 另请检查以获取进一步参考 作为一种解决方法,在修复jQuery错误或修补Fancybox时回滚到
更新(2013年1月16日):Fancybox已经发布,现在它可以与jQuery v1.9.0配合使用 对于fancybox v1.3.4-您仍然需要回滚到,或者应用@Manu的答案所指出的
更新(2013年1月17日):Fancybox v1.3.4用户的解决方案: 对进行修补,使其与jQuery v1.9.0配合使用,如下所示:
$.browser.msie
替换为第615行附近的navigator.userAgent.match(/msie[6]/i)
(和/或替换所有$.browser.msie
实例,谢谢
... 就这样或者,您可以回滚到或应用@Manu的答案中指出的。您好,这是由于jQuery=>1.9.0的新版本 您可以检查更新: 不推荐使用jQuery.Browser。 您可以通过添加迁移脚本来保留最新版本: 替换:
<script src="http://code.jquery.com/jquery-latest.js"></script>
作者:
在您的页面及其工作环境中。全局事件也不推荐使用 以下是修复浏览器和事件问题的修补程序:
--- jquery.fancybox-1.3.4.js.orig 2010-11-11 23:31:54.000000000 +0100
+++ jquery.fancybox-1.3.4.js 2013-03-22 23:25:29.996796800 +0100
@@ -26,7 +26,9 @@
titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
- isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
+ isIE = !+"\v1",
+
+ isIE6 = isIE && window.XMLHttpRequest === undefined,
/*
* Private methods
@@ -322,7 +324,7 @@
loading.hide();
if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
- $.event.trigger('fancybox-cancel');
+ $('.fancybox-inline-tmp').trigger('fancybox-cancel');
busy = false;
return;
@@ -389,7 +391,7 @@
content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
};
- $.event.trigger('fancybox-change');
+ $('.fancybox-inline-tmp').trigger('fancybox-change');
content
.empty()
@@ -612,7 +614,7 @@
}
if (currentOpts.type == 'iframe') {
- $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
+ $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + (isIE ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
}
wrap.show();
@@ -912,7 +914,7 @@
busy = true;
- $.event.trigger('fancybox-cancel');
+ $('.fancybox-inline-tmp').trigger('fancybox-cancel');
_abort();
@@ -957,7 +959,7 @@
title.empty().hide();
wrap.hide();
- $.event.trigger('fancybox-cleanup');
+ $('.fancybox-inline-tmp, select:not(#fancybox-tmp select)').trigger('fancybox-cleanup');
content.empty();
——jquery.fancybox-1.3.4.js.orig 2010-11-11 23:31:54.000000000+0100
+++jquery.fancybox-1.3.4.js 2013-03-22 23:25:29.996796800+0100
@@ -26,7 +26,9 @@
titleLight=0,titleStr='',start_pos,final_pos,busy=false,fx=$.extend($('')[0],{prop:0}),
-isIE6=$.browser.msie&$.browser.version<7&&!window.XMLHttpRequest,
+伊西=+“\v1”,
+
+isIE6=isIE&&window.XMLHttpRequest==未定义,
/*
*私有方法
@@ -322,7 +324,7 @@
loading.hide();
if(wrap.is(“:visible”)&&false==currentOpts.onCleanup(currentArray、currentIndex、currentOpts)){
-$.event.trigger('fancybox-cancel');
+$('.fancybox inline tmp')。触发器('fancybox-cancel');
忙=假;
返回;
@@ -389,7 +391,7 @@
html(tmp.contents()).fadeTo(currentOpts.changefead,1,_finish);
};
-$.event.trigger('fancybox-change');
+$('.fancyboxinlinetmp').trigger('fancybox-change');
内容
.empty()
@@ -612,7 +614,7 @@
}
if(currentOpts.type==“iframe”){
-$('')。附录(内容);
}
wrap.show();
@@ -912,7 +914,7 @@
忙=真;
-$.event.trigger('fancybox-cancel');
+$('.fancybox inline tmp')。触发器('fancybox-cancel');
_中止();
@@ -957,7 +959,7 @@
title.empty().hide();
wrap.hide();
-$.event.trigger('fancybox-cleanup');
+$('.fancybox inline tmp,select:not(#fancybox tmp select)).trigger('fancybox-cleanup');
content.empty();
如果任何人仍然必须支持使用jQuery 3.0+的旧式fancybox,您还需要做一些其他更改:
.unbind()已弃用
将.unbind
的所有实例替换为.off
.removeAttribute()不是函数
将第580-581行更改为使用jQuery的.removeAttr()
:
旧代码:
580: content[0].style.removeAttribute('filter');
581: wrap[0].style.removeAttribute('filter');
新代码:
580: content.removeAttr('filter');
581: wrap.removeAttr('filter');
这与上面提到的其他补丁相结合,解决了我的兼容性问题。这就是为什么您永远不应该在生产中使用
jquery latest.js
!使用fancybox 2.1.5的最新版本,在从Google Ajax库API CDN中提取后,我发现了同样的问题。这导致jQuery的最新版本1.9.0出现问题。我们将v1.8.3版本拉下来,在本地web服务器上指向它,现在一切都已修复。显然,我们希望使用CDN,但不会以破坏滑块和悬停菜单为代价。为什么要编写正则表达式/msie[6]/i
字符类[6]
与字符6
完全相同,即没有括号。这并不能激发人们对代码的信心…:/@ZrajmCAkfohg:我猜是因为我通常会验证IE版本6到8的版本,在这种情况下,它只是作为[6]
,最后只是一个语法约定。无论如何,如果它们“完全相等”,那么这会如何影响对代码的信心?!?!如果带括号或不带括号的结果不同,这会造成混淆,那么我同意你的看法,否则我看不出你的“…不会激发信心…”评论非常有建设性。我
--- jquery.fancybox-1.3.4.js.orig 2010-11-11 23:31:54.000000000 +0100
+++ jquery.fancybox-1.3.4.js 2013-03-22 23:25:29.996796800 +0100
@@ -26,7 +26,9 @@
titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
- isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
+ isIE = !+"\v1",
+
+ isIE6 = isIE && window.XMLHttpRequest === undefined,
/*
* Private methods
@@ -322,7 +324,7 @@
loading.hide();
if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
- $.event.trigger('fancybox-cancel');
+ $('.fancybox-inline-tmp').trigger('fancybox-cancel');
busy = false;
return;
@@ -389,7 +391,7 @@
content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
};
- $.event.trigger('fancybox-change');
+ $('.fancybox-inline-tmp').trigger('fancybox-change');
content
.empty()
@@ -612,7 +614,7 @@
}
if (currentOpts.type == 'iframe') {
- $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
+ $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + (isIE ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
}
wrap.show();
@@ -912,7 +914,7 @@
busy = true;
- $.event.trigger('fancybox-cancel');
+ $('.fancybox-inline-tmp').trigger('fancybox-cancel');
_abort();
@@ -957,7 +959,7 @@
title.empty().hide();
wrap.hide();
- $.event.trigger('fancybox-cleanup');
+ $('.fancybox-inline-tmp, select:not(#fancybox-tmp select)').trigger('fancybox-cleanup');
content.empty();
580: content[0].style.removeAttribute('filter');
581: wrap[0].style.removeAttribute('filter');
580: content.removeAttr('filter');
581: wrap.removeAttr('filter');