开发者

jQuery - IE ONLY css

开发者 https://www.devze.com 2023-04-04 17:12 出处:网络
Is it possible to use var script = document.createElement(\'link\'); script.href = \'theme/style/ie/manageleads.css\';

Is it possible to use

var script = document.createElement('link');
script.href = 'theme/style/ie/manageleads.css';
script.rel  = 's开发者_运维问答tylesheet';
script.type = 'text/css';
document.getElementsByTagName('head')[0].appendChild(script);

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


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

Note that IE8 claims to be 7 in Compatibility View.

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


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

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

If that doesn't work, let me know. You might need to use 'document.createStylesheet' instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消