Re: JS: browser AND platform detection COMBINED

by "Cyanide _7" <leo7278(at)hotmail.com>

 Date:  Thu, 20 Jan 2000 09:45:30 CST
 To:  WebProgrmr(at)aol.com
 Cc:  hwg-languages(at)hwg.org
  todo: View Thread, Original
try this. it doesn't get incredibly specific with platforms. it doesn't test 
for OS/2 or versions of windows. so take into consideration that win3.0 and 
win98 are treated the same, etc...

agt = navigator.userAgent.toLowerCase();
app = navigator.appName;

is_MAC = (agt.indexOf("mac")!=-1);
is_PC = (agt.indexOf("win")!=-1);

is_NN = (app.indexOf("Netscape")!=-1);
is_IE = (app.indexOf("Microsoft")!=-1);

css = "defalt.css";

if (is_MAC && is_NN)
  css = "mac_nn.css";
else if (is_MAC && is_IE)
  css = "mac_ie.css";
else if (is_PC && is_NN)
  css = "pc_nn.css";
else if (is_PC && is_IE)
  css = "pc_ie.css";

- Cyanide_7

>From: WebProgrmr(at)aol.com
>To: hwg-languages(at)hwg.org
>Subject: JS: browser AND platform detection COMBINED
>Date: Thu, 20 Jan 2000 01:26:22 EST
>
>I'm a project manager on a non-profit development team.  Unfortunately, my
>volunteer JS coder can't figure out this problem.
>
>I want to detect for a browser AND platform.  Based on the answer, a CSS
>document will be linked.  Logically speaking, this should be five lines of
>code.
>
>if browser == IE && platform == PC, then ...  get CSS for IE/PC
>else if browser == IE && platform == MAC, then ...  get CSS for IE/MAC
>else if browser == NN && platform == PC, then ...  get CSS for NN/PC
>else if browser == NN && platform == MAC, then ...  get CSS for NN/MAC
>else get CSS for OTHER
>
>I've seen free code on irt.org for simple browser detection, but now I need
>to add in the platform detection.
>
>Thanks for your help.  If you have a solution, please email me directly in
>addition to the list. :)
>++Dan

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA