Login Register






CSS for different browsers filter_list
Author
Message
CSS for different browsers #1
This is the piece of code I wrote and I would like to share with you guys. Smile

It shows how to load different stylesheets depending on the browser that the user is currently browsing, in order to be able to conduct a simple and efficient crossbrowser. We’ll use the jQuery JavaScript library.
The code checks whether the browser is IE (msie). If not, they test to see if it's Firefox, and if you're not, the same applies the stylesheet related to Chrome.

It is very useful for mobile coding too.

Code:
<script type="text/javascript"> $(document).ready(function() { if($.browser.msie){ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_explorer.css" }); } else if ($.browser.mozilla){ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_firefox.css" }); } else{ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_chrome.css" }); } )}; </script>

Hope you liked it! Smile
Yar-har Fiddle-dee-dee, being a pirate is alright to be! Do what you want cause a pirate is free, you are a pirate! AHOY!


[Image: tumblr_m7isvt2N171ranhnao1_500.gif]

Reply

CSS for different browsers #2
This is the piece of code I wrote and I would like to share with you guys. Smile

It shows how to load different stylesheets depending on the browser that the user is currently browsing, in order to be able to conduct a simple and efficient crossbrowser. We’ll use the jQuery JavaScript library.
The code checks whether the browser is IE (msie). If not, they test to see if it's Firefox, and if you're not, the same applies the stylesheet related to Chrome.

It is very useful for mobile coding too.

Code:
<script type="text/javascript"> $(document).ready(function() { if($.browser.msie){ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_explorer.css" }); } else if ($.browser.mozilla){ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_firefox.css" }); } else{ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_chrome.css" }); } )}; </script>

Hope you liked it! Smile
Yar-har Fiddle-dee-dee, being a pirate is alright to be! Do what you want cause a pirate is free, you are a pirate! AHOY!


[Image: tumblr_m7isvt2N171ranhnao1_500.gif]

Reply

CSS for different browsers #3
This is the piece of code I wrote and I would like to share with you guys. Smile

It shows how to load different stylesheets depending on the browser that the user is currently browsing, in order to be able to conduct a simple and efficient crossbrowser. We’ll use the jQuery JavaScript library.
The code checks whether the browser is IE (msie). If not, they test to see if it's Firefox, and if you're not, the same applies the stylesheet related to Chrome.

It is very useful for mobile coding too.

Code:
<script type="text/javascript"> $(document).ready(function() { if($.browser.msie){ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_explorer.css" }); } else if ($.browser.mozilla){ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_firefox.css" }); } else{ $("head").append("<link>"); css = $("head").children(":last"); css.attr({ rel: "stylesheet", type: "text/css", href: "http://www.yoursite.com/css/style_chrome.css" }); } )}; </script>

Hope you liked it! Smile
Yar-har Fiddle-dee-dee, being a pirate is alright to be! Do what you want cause a pirate is free, you are a pirate! AHOY!


[Image: tumblr_m7isvt2N171ranhnao1_500.gif]

Reply

RE: CSS for different browsers #4
Nice little jQuery code.
Its good that jQuery supports all browsers. Otherwise this IE troubles too much when it comes to client sided coding.
Btw, are you a jQuery pro?
[Image: 2YpkRjy.png]
PM me if you need help.
My pastebin HERE. My URL Shortener HERE.

Reply

RE: CSS for different browsers #5
Nice little jQuery code.
Its good that jQuery supports all browsers. Otherwise this IE troubles too much when it comes to client sided coding.
Btw, are you a jQuery pro?
[Image: 2YpkRjy.png]
PM me if you need help.
My pastebin HERE. My URL Shortener HERE.

Reply

RE: CSS for different browsers #6
Quote:Its good that jQuery supports all browsers. Otherwise this IE troubles too much when it comes to client sided coding.

Exactly!

Quote:Btw, are you a jQuery pro?

I wouldn't call myself a pro haha Smile but i'm always looking for new codes and plugins to study and learn a thing or two :lol:
Yar-har Fiddle-dee-dee, being a pirate is alright to be! Do what you want cause a pirate is free, you are a pirate! AHOY!


[Image: tumblr_m7isvt2N171ranhnao1_500.gif]

Reply

RE: CSS for different browsers #7
Quote:Its good that jQuery supports all browsers. Otherwise this IE troubles too much when it comes to client sided coding.

Exactly!

Quote:Btw, are you a jQuery pro?

I wouldn't call myself a pro haha Smile but i'm always looking for new codes and plugins to study and learn a thing or two :lol:
Yar-har Fiddle-dee-dee, being a pirate is alright to be! Do what you want cause a pirate is free, you are a pirate! AHOY!


[Image: tumblr_m7isvt2N171ranhnao1_500.gif]

Reply

RE: CSS for different browsers #8
Very handy bit of code that, I'm guessing it will support Opera Mini aswell?

Reply

RE: CSS for different browsers #9
Very handy bit of code that, I'm guessing it will support Opera Mini aswell?

Reply

RE: CSS for different browsers #10
Quote:Very handy bit of code that, I'm guessing it will support Opera Mini aswell?

Yep! It does support because Opera Mini is B-graded by jquery(Full experience without Ajax navigation features). Smile
Yar-har Fiddle-dee-dee, being a pirate is alright to be! Do what you want cause a pirate is free, you are a pirate! AHOY!


[Image: tumblr_m7isvt2N171ranhnao1_500.gif]

Reply