Ok here's the deal. I want to create 2 seperate css files, one for IE and one for Mozilla because I have noticed serious positioning differences between the 2 browsers. I would like to add a javascript that detects which browser the user is using, and then load the correct css file depending on the browser type. Has anyone done anything like this before, or does anyone know of a script I could use that would make this work?
Philip M
02-03-2005, 07:37 PM
Well, yes. I think one or two people may have done this before, if only in the privacy of their own homes.
There are a zillion scripts out there. Try for example
http://www.javascriptkit.com/script/cut5.shtml
djimenez
02-03-2005, 07:50 PM
Thanks, for the link but that script merely does a redirect to a different HTML page, I am actually more interested in a detection script that would have else if statements regarding which css file to load into one specific html page. I have a vague idea how i would write it but I want to see if this is even a good idea, or if i should try something else.
A1ien51
02-03-2005, 08:31 PM
Learn to use google: http://www.google.com/search?hl=en&q=style+sheet+based+on+browser+JavaScript
It helps get your answer asked quicker!
Eric
PROWEBWORKS.NET
02-03-2005, 09:32 PM
This goes inside the <head></head>
<SCRIPT language="JavaScript">
<!--
var browserName=navigator.appName;
if (browserName=="Netscape")
{
document.write('<link rel="stylesheet" href=http://www.codingforums.com/archive/index.php/"ns_stylesheet.css" type="text/css">')
}
else
{
document.write('<link rel="stylesheet" href=http://www.codingforums.com/archive/index.php/"ie_stylesheet.css" type="text/css">')
}
//-->
</script>
Philip M
02-04-2005, 07:39 AM
In fact this question was answered very recently at
http://www.codingforums.com/showthread.php?t=51553
using the IE conditional [if IE]
which is perhaps a simpler solution.