...

View Full Version : How to Detect A Browser



cshumate
07-15-2009, 07:04 AM
I want to set up my website so it is compatible with all browsers and older versions of IE. So far in order to detect browsers and which version, I have this snippet of code...

<script type="text/javascript">
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
</script>

Ultimately what I want it to do is detect which browser is loading the page and after it determines which browser it will call up the appropriate CSS file to make sure it looks right in the browser.

In other words the code would say...

if the browser is Firefox, then load this css file
if the browser is IE but the version is less than 7, then load this cascading style sheet.

I just don't know how to code this appropriately,

Thanks!

Philip M
07-15-2009, 07:16 AM
http://www.javascriptkit.com/javatutors/objdetect3.shtml



<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="IEspecific.css" />
<![endif]-->

<!--[if !IE]>
<link rel="stylesheet" type="text/css" href="allbutIE.css" />
<![endif]-->




What about IE7+?

It is your responsibility to die() if necessary….. - PHP Manual



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum