By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,624 Members | 2,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,624 IT Pros & Developers. It's quick & easy.

Browser Detection for CSS

P: 8
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
Share this Question
Share on Google+
4 Replies


P: 8
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 5K+
P: 7,435
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

P: 8
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 5K+
P: 7,435
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.