[thelist] Platform Detection and CSS

Tom Dell'Aringa pixelmech at yahoo.com
Mon Jun 24 22:04:01 CDT 2002


I think part of what Erik was trying to say is what I will say - I probably wouldn't use browser
detect, its too cumbersome and unreliable unless you have no choice. I would use object detection.
Head over to Peter-Pauls site

http://www.xs4all.nl/~ppk/js/index.html?/~ppk/js/display.html

and read under General/Object detect, he explains it well. I think between that and handling the
differences within CSS is a better way to go.

Good Luck

Tom


--- Blake Coglianese <blake at focusednrg.com> wrote:
> Hi all,
>
> I am trying to create a JavaScript that detects the browser and os. I then
> want the JavaScript to write the linked style sheet. It is working on Mac in
> both IE and Netscape but I cannot get it to work on a windows machine. Im
> not much of a JavaScript programmer so any help would be appreciated. The
> script I am using is below.
>
> <script language="JavaScript" type="text/JavaScript">
>
>  if(navigator.userAgent.indexOf('Mac') != -1 &&
> navigator.appName.indexOf("Netscape")>(-1))
> {
>  document.write('<link rel=stylesheet href="css/wsNetscapeMac.css"
> type="text/css">')
> }
>  else if(navigator.userAgent.indexOf('Mac') != -1 &&
> navigator.appName.indexOf("Explorer")>(-1))
> {
>  document.write('<link rel=stylesheet href="css/wsIEMac.css"
> type="text/css">')
> }
>  else if(navigator.userAgent.indexOf('win') != -1 &&
> navigator.appName.indexOf("Netscape")>(-1))
> {
>  document.write('<link rel=stylesheet href="css/wsNetscapeMWin.css"
> type="text/css">')
> }
>  else (navigator.userAgent.indexOf('win') != -1 &&
> navigator.appName.indexOf("Explorer")>(-1))
> {
>  document.write('<link rel=stylesheet href="css/wsIEMWin.css"
> type="text/css">')
> }
> </script>
>
> TIA,
>
> Blake
> blake at focusednrg.com
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the thelist mailing list