loading firefox specific css for a different background
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/ )
精彩评论