473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
4 2530
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
7,435 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
7,435 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

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

Similar topics

7
by: Szar | last post by:
JS noob. I've seen plenty of browser detection scripts but they all seem to be slightly different and don't really fit my needs. I have various places where if the browser is IE I'd like to display...
17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
8
by: R. Smits | last post by:
I've have got this script, the only thing I want to be changed is the first part. It has to detect IE version 6 instead of just "Microsoft Internet Explorer". Can somebody help me out? I tried...
8
by: Jimnbigd | last post by:
What is the recommended code to test browser type, for conditional processing in Javascript? I have seen tests for "document.all". I have seen tests for the actual browser name, or substrings in...
7
by: phal | last post by:
Hi I think there are many different browsers to browse to the Internet, how can I write the javascript to identify different browser and display according to the users. Some browser disable the...
4
by: trpost | last post by:
I am looking for a script using javascript to pull browser information including, browser type and version, OS info, plugins (flash, acrobat, media player, etc), java version, etc. that will work...
15
by: CMM | last post by:
So I'm half way through overseeing a large project in ASP.NET 2.0. My superiors have decided that it would be nice if we ensured the site worked on all the major platforms (as they see it: IE,...
16
by: petermichaux | last post by:
Hi, Does anyone have a a cross-browser setOpacity function that does not use browser sniffing? I looked at the Yahoo! UI function and it detects IE by looking for window.ActiveXObject. I also...
7
by: Nathan Sokalski | last post by:
I want to make sure I am doing a browser detection that will work once IE7 is released. My current detection statement (written using VB.NET) is: If Me.Request.Browser.Browser.ToUpper() = "IE"...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.