0

I've the latest version of jQuery and trying to use fancybox, but these messages always appear:

Uncaught TypeError: Cannot read property 'msie' of undefined

Uncaught TypeError: $(...).fancybox is not a function

I tried jQuery.noConflict() too, and my jQuery is loaded before the fancybox.js

Community
  • 1
  • 1
  • Can you please post your HTML and JavaScript, the most likely reason for this error is that the JQuery library is not loaded correctly. – Alex Feb 03 '16 at 13:49
  • It looks like you haven't included the fancybox library and are using a version of jQuery from the 2.x branch which does not have the browser sniffing methods included. – Rory McCrossan Feb 03 '16 at 13:52
  • actually `$.browser` was deprecated: 1.3 and removed: 1.9 and is available only through the jQuery.migrate plugin - From jquery docs https://api.jquery.com/jquery.browser/ – wirey00 Feb 03 '16 at 14:00
  • i'm using jquery.fancybox-1.3.4.pack.js and jquery-1.12.0.min.js. Jquery is loaded first, then fancybox.js and then script.js where i try to use fancybox() function – Bidzina Aivazashvili Feb 03 '16 at 14:01
  • Any errors in your console? @BidzinaAivazashvili – wirey00 Feb 03 '16 at 14:02
  • Yeah, these errors appear in my console. Uncaught TypeError: Cannot read property 'msie' of undefined Uncaught TypeError: $(...).fancybox is not a function – Bidzina Aivazashvili Feb 03 '16 at 14:04
  • 1
    Jquery migrate plugin helped me ! Thanks guys, especially to you ! @ᾠῗᵲᄐᶌ – Bidzina Aivazashvili Feb 03 '16 at 14:18

1 Answers1

0

have you tried using the new fancybox instead? http://fancyapps.com/fancybox/

This is the first couple lines in the jquery.fancybox-1.3.4.js file

;(function($) {
    var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,    
        selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],    
        ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,    
        loadingTimer, loadingFrame = 1,    
        titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),    
        isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

It'll fail here

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

because jquery.browser has been removed as of 1.9 unless you include jquery.migrate https://api.jquery.com/jquery.browser/

Since it fails there - $.fancybox never get's a chance to get declared so that's why you're getting the 2 errors.

The new fancybox doesn't use jQuery.browser and is using IE = navigator.userAgent.match(/msie/i) instead

So you have to choose 1 of the below

  1. use new fancybox
  2. use an older jquery library
  3. include jquery.migrate
wirey00
  • 33,517
  • 7
  • 54
  • 65