FAQ: CSS Browser Detect
CSS is interpreted differently by Microsoft and Netscape browsers. To have a consistent look, you can create two CSS (one for each browser) and use this JavaScript to detect the browser and decide which CSS file to use.
This browser detect JavaScript was written by Brett Burridge. It detects the browser and then writes a <link REL...> into your header.
To use this, create two CSS files. I named them style-ie.css (for Microsoft) and style-ns.css (for Netscape.)
<head>
<!-- CSS Browser Detect BEGIN -->
<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='style-ie.css' TYPE='text/css'>");
}
else if (browser_type == "Netscape" && (browser_version >= 4)) {
document.write("<link REL='stylesheet' HREF='style-ns.css' TYPE='text/css'>");
}
// --></script>
<!-- CSS Browser Detect END -->
</head>
Is this Page Useful? Vote!
Updates: andreas.com newsletter
I add new pages every month. Sign up with your email and I'll drop you a note (not more than once a month) about new pages. (See more about the newsletter.) |
|
|