Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
83
rated 0 times [  86] [ 3]  / answers: 1 / hits: 23533  / 11 Years ago, fri, may 3, 2013, 12:00:00

As many already posted in other questions (also in jQuery documentation), the old jQuery.browser.version is deprecated and works only in jquery1.3.



Do you know another simple way to detect it, that I can include in my code before:



function handleInfoDivPopupVisibility(dynamicEleId, staticEleId){
var parentContainer = $('headerSummaryContainer');
var dynamicEle = $(dynamicEleId);
var staticEle = $(staticEleId);

if(isIE() && parentContainer){
if (jQuery.browser.version != 10) { // I need to find a way to detect if it's IE10 here.
parentContainer.style.overflow = 'visible';
}
}
dynamicEle ? dynamicEle.style.display = '' : '';
if(dynamicEle && staticEle)
gui_positionBelow(dynamicEle, staticEle);
}


Before you say it's duplicated question of this or this, I'd like to reinforce that I don't want to use css hacks. Is there a way to detect it just as simple as I could do before?



if (jQuery.browser.version != 10) {...

More From » jquery

 Answers
2

In general it's a bad idea to check for browser version, it's considered a better practice to check for browser features. But if you're sure what you're doing:



function getIEVersion(){
var agent = navigator.userAgent;
var reg = /MSIEs?(d+)(?:.(d+))?/i;
var matches = agent.match(reg);
if (matches != null) {
return { major: matches[1], minor: matches[2] };
}
return { major: -1, minor: -1 };
}

var ie_version = getIEVersion();
var is_ie10 = ie_version.major == 10;


We have the following code in production, so it works and well-tested.



And yes, we did have a need to detect IE10, not just a particular feature that exists in IE10 but not in earlier versions.


[#78441] Thursday, May 2, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaelynncherokeeg

Total Points: 697
Total Questions: 109
Total Answers: 104

Location: France
Member since Thu, Mar 18, 2021
3 Years ago
jaelynncherokeeg questions
Thu, May 27, 21, 00:00, 3 Years ago
Fri, Jan 24, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
Wed, Sep 18, 19, 00:00, 5 Years ago
;