开发者

loading firefox specific css for a different background

开发者 https://www.devze.com 2023-04-05 09:01 出处:网络
Here\'s the deal, I have a jQuery plugin I am using that works best in Safari and Chrome..It slows down Firefox.. But, not using the plugin isn\'t an option because it\'s just 开发者_开发问答so awesom

Here's the deal, I have a jQuery plugin I am using that works best in Safari and Chrome.. It slows down Firefox.. But, not using the plugin isn't an option because it's just 开发者_开发问答so awesome.

What I want to do is load a different background for Firefox and not any other browser.. How do I accomplish this with CSS, or jQuery?


You could use a conditional comments to load a different style sheet or detect the browser with jQuery:


if ($.browser.mozilla && $.browser.version >= "1.8" )                     
    $("body").css("background-image", "firefox-background.jpg" );


Although i discourage this, here's some rough code

var imageUrl = 'your url'; 
if( $.browser.mozilla ) 
    $('#yourelement').css('background-image', 'url(' + imageUrl + ')' ); 
else 
    $('#yourelement').css('background-image', 'url(' + imageUrl + ')' );


I would suggest you to use some browser detection plugin. Also this ( and lots of other things ) can be done with head.js ( http://headjs.com/ )

0

精彩评论

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

关注公众号