I need to detect not only the browser type but version as well using jQuery. Mostly I need to find out if it is IE 8 or not.
I am not sure if I am doing it correctly.
If I do :
if (jQuery.browser.version >= 8.0) { dosomething}
I am not sure it will work for version 8.123.45.6 or will it?
Edit: Note that JQuery 2+ has dropped support for IE8 and below, and therefore can no longer be used to detect IE8. If using a current version of JQuery, it is necessary to use a Non-JQuery solution.
1 Answer. Show activity on this post. IE8 support was dropped in jQuery 2. x, so you will want any version beginning with 1 that satisfies your plugin's version dependencies.
You can test if jQuery is loaded by opening your javascript console (in Chrome: Settings > More tools > Javascript console). Where the little blue arrow appears type: if(jQuery) alert('jQuery is loaded'); Press enter.
I think the best way would be this:
From HTML5 boilerplate:
<!--[if lt IE 7]> <html lang="en-us" class="no-js ie6 oldie"> <![endif]--> <!--[if IE 7]> <html lang="en-us" class="no-js ie7 oldie"> <![endif]--> <!--[if IE 8]> <html lang="en-us" class="no-js ie8 oldie"> <![endif]--> <!--[if gt IE 8]><!--> <html lang="en-us" class="no-js"> <!--<![endif]-->
in JS:
if( $("html").hasClass("ie8") ) { /* do your things */ };
especially since $.browser
has been removed from jQuery 1.9+.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With