JQuery - IE ONLY css ONLY

Can i use

var script = document.createElement('link'); script.href = 'theme/style/ie/manageleads.css'; script.rel = 'stylesheet'; script.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(script); 

and for him to be active only if the browser is IE8?

+4
source share
2 answers

http://api.jquery.com/jQuery.browser/

Note that IE8 claims to have 7 in a compatibility view.

 if ($.browser == 'msie' && (parseInt($.browser.version) == 8 || parseInt($.browser.version) == 7)) { // Do something IE8-only in here } 
+7
source

The best way would be conditional CSS, but since you asked for jQuery, here you go.

 if ($.browser.msie && parseInt($.browser.version) == 8) { $('<link />', { href: 'theme/style/ie/manageleads.css', rel: 'stylesheet', type: 'text/css' }).appendTo('head'); } 

If this does not work, let me know. You may need to use 'document.createStylesheet'.

+2
source

All Articles