javascript - jQuery - IE ONLY css - Stack Overflow

Is it possible to use var script = document.createElement('link');script.href = 'theme

Is it possible to 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 it to only be active if the browser is IE8?

Is it possible to 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 it to only be active if the browser is IE8?

Share Improve this question edited Nov 5, 2014 at 11:22 Joe 15.8k4 gold badges50 silver badges83 bronze badges asked Sep 12, 2011 at 2:37 RussellHarrowerRussellHarrower 6,85025 gold badges113 silver badges225 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

http://api.jquery./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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745361016a4624358.html

相关推荐

  • javascript - jQuery - IE ONLY css - Stack Overflow

    Is it possible to use var script = document.createElement('link');script.href = 'theme

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信