467,874 Members | 1,748 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,874 developers. It's quick & easy.

Browser Detection for CSS

I figured i could easily solve my problem if i used a detectin script so a differant CSS could be used for each browser.
So i found this:

Expand|Select|Wrap|Line Numbers
  1. <!-- CSS Browser Detect BEGIN -->
  2. <script language="JavaScript"><!--
  3. browser_version = parseInt(navigator.appVersion);
  4. browser_type = navigator.appName;
  5.  
  6. if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) {
  7. document.write("<link REL='stylesheet' HREF='CSS/IECSS.css' TYPE='text/css'>");
  8.  
  9. else if (browser_type == "*Mozilla*" && (browser_version >= 1)) {
  10. document.write("<link REL='stylesheet' HREF='CSS/FFCSS.css' TYPE='text/css'>");
  11.  
  12. // --></script>
  13. <!-- CSS Browser Detect END -->
  14.  
(This is slightly edited tho, but only the browser_type)

So, i was trying to get it too detect FireFox, but i cant figure out what the browser type would be for this.

Anyone have any ideas?
Jan 18 '08 #1
  • viewed: 2237
Share:
4 Replies
Nevermind, i may have found a solution for firefox.

Instead of trying to make one specifically for Firefox, i just made a 'else' line.


Now i need help with opera :D
Jan 18 '08 #2
drhowarddrfine
Expert 4TB
I don't know of any reason to do it this way. If you write your CSS to the W3C standard, the ony browser that may give you problems is IE. Trying to create a different stylesheet for each browser is a waste of time.
Jan 18 '08 #3
But you see, time i have.

This is coursework anyway. And all i do is copy the style sheets and alter them slightly so they look just perfect for each browser.

(And i dont do all browsers, so far ive done Internet Explorer, Netscape - which also does firefox) and Opera)

Anyway. Think ive got it all sorted... kinda :/
Jan 18 '08 #4
drhowarddrfine
Expert 4TB
Conditional Love
Kinda is the problem. You are, in a way, writing several stylesheets when one may do. If you want to learn, learn the way it's done. Multiple stylesheets is not the way it's done.
Jan 18 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Szar | last post: by
8 posts views Thread by R. Smits | last post: by
8 posts views Thread by Jimnbigd | last post: by
4 posts views Thread by trpost | last post: by
15 posts views Thread by CMM | last post: by
7 posts views Thread by Nathan Sokalski | last post: by
10 posts views Thread by Conrad Lender | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.