Forum Moderators: open

Message Too Old, No Replies

browser detection and specific css

how to have different style sheets for about 5 different browsers

         

still learning

2:51 pm on Aug 16, 2005 (gmt 0)

10+ Year Member



Hello,

I'm really not good with Javascript.
So far, here is what I wrote:

---------------------------------------------------------
<script language="JavaScript"><!--
browser_version= parseInt(navigator.appVersion);
browser_type = navigator.appName;

if (browser_type == "Microsoft Internet Explorer" && (browser_version >= 4)) {
document.write("<link REL='stylesheet' HREF='css/ie.css' TYPE='text/css'>");
}

else {
document.write("<link REL='stylesheet' HREF='css/other-browsers.css' TYPE='text/css'>");
}

// --></script>
-------------------------------------------------------

But now I realise I also want a separate style sheet for IE on Mac, for Safari, and Opera.

How do I do that?

In most of what I found on the web, people seem to define one style sheet for IE and one for Netscape. Why is that? Does 'Netscape' include all the other browsers?

Thanks a lot

albo

3:04 pm on Aug 16, 2005 (gmt 0)

10+ Year Member



In my experience one for Netscape and one for IE seems to suffice *most* but not *all* of the time. Remember your pal the client can have javascript turned off so it's best to set up your css so it's somewhat cover-all. Opera can disguise itself as Netscape or IE. These issues are somewhat discussed in O'Reilly CSS series of books

RonPK

3:16 pm on Aug 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Five different CSS-files? That means lots of unnecessary maintenance overhead. If possible, use one file and apply CSS hacks where necessary.

still learning

4:59 pm on Aug 16, 2005 (gmt 0)

10+ Year Member



thanks for your replies.

I guess 2 style sheets could be enough, and I wouldn't mind if the site was slightly imperfect in some browsers.

the problem is, it's for my MA's final project and I know that I'll have to present it on a Mac, which is really unfair because not many people use it.

I have many problems with Mac browsers. Some are about alignment, but I also have problems with javaScript. I'm not a programmer and I find hard to understand the css hacks. but i'm going to try!