bgiframe with jquery browser

1k views Asked by At

Here is my old jQuery code using jQuery 1.5 version. works

jQuery.fn.ShowPageMask = function() { 
    var maskHeight = $(document).height(); 
    if ($.browser.msie && parseInt($.browser.version) < 7) { 
        $('#pageMask').bgiframe(); 
    } 

    $('#pageMask').css({ 'filter': "alpha(opacity=50)" }); 
    $('#pageMask').css({ '-moz-opacity': "0.6" }); 
    $('#pageMask').css({ '-khtml-opacity': "0.6" }); 
    $('#pageMask').css({ 'opacity': "0.6" }); 
    $('#pageMask').show(); 
    $(window).resize(function() { 
        $('#pageMask').setFullWidth(); 
    });

Now we updated to jQuery 1.9.1 recently and getting error $.browser

Here instead of checking the browser version and name, we should check the feature support. But i dont really understand, how can I check this below scenario with feature.. What feature i should detect?

if ($.browser.msie && parseInt($.browser.version) < 7) { 
    $('#pageMask').bgiframe(); // why the hell it is for IE<7
} 
1

There are 1 answers

0
jfriend00 On

You have several options:

1) Unless you still need to support IE6, you can just remove these three lines:

if ($.browser.msie && parseInt($.browser.version) < 7) { 
    $('#pageMask').bgiframe(); 
} 

2) The current version of the plugin already tests for IE 6 and is, by default, only active if the browser is IE 6. It uses the userAgent string to identify IE 6.

So, you can change this:

if ($.browser.msie && parseInt($.browser.version) < 7) { 
    $('#pageMask').bgiframe(); 
} 

to just this:

$('#pageMask').bgiframe(); 

And, it will simply do nothing for browsers that aren't IE 6.


3) If you wanted to use feature detection, you would need to devise a feature detection algorithm for the very problem that this plug-in is trying to fix. If the problem is present, then use the plug-in. If the problem is not persent, then you don't need the plug-in. I don't quite understand what problem the plug-in is trying to fix so I'm not sure how to advise you here.