| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Css and Browser switching
Does anyone know of a javascript or some coding that allows you to switch style sheets based on the borowser being used.
I tried this script and it does not work. <SCRIPT LANGUAGE="Javascript"> <!-- var bIsIE = navigator.appName == "Microsoft Internet Explorer" var bIsIE4 = bIsIE && navigator.appVersion.indexOf("4.0") > -1 if (bIsIE4) { sCSS = '<LINK REL="stylesheet" TYPE="text/css" HREF="nfi2.css">' } else { if (bIsNS) { sCSS = '<LINK REL="stylesheet" TYPE="text/css" HREF="nfi2mo.css">' } } document.write(sCSS) file://--> </SCRIPT> |
|
#2
|
||||
|
||||
|
I don't have a specific script, but I do know you should be checking the browser capabilities rather than it's name to determine which CSS, or any other element, you should use. A search for something like browser capabilites detection, or browser sniffing, should lead you in the right direction.
__________________
-
thought-after | my thoughts on web development Get Firefox, the developers browser Budget hosting - recommended [/left] |
|
#3
|
||||
|
||||
|
That was some UGLY javascript. Try something like this as a starting point:
Code:
<script language="JavaScript"
type="text/JavaScript">
if(navigator.appName == "Microsoft Internet Explorer") {
document.write("<link href=\"ie.css\" rel=\"stylesheet\" type=\"text/css\" />");
}
else {
document.write("<link href=\"nn.css\" rel=\"stylesheet\" type=\"text/css\" />");
}
</script>
__________________
If you found a post of mine helpful, please click on the on my post to add to my reputation.
|
|
#4
|
||||
|
||||
|
I do have to point out that if you developed your site in XHMTL, used CSS, and developed according to standards then you would NOT have to detect which browser the visitor is using.
|
![]() |
| Viewing: ASP Free Forums > Web Design > Web Layout > Css and Browser switching |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|