Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>HELP!! Browser Detection with JScript

HELP!! Browser Detection with JScript

djimenez
02-03-2005, 07:22 PM
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.


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

can not call click() in Firefox or Mozilla
Trouble with Status/Progress Window
tool tips, alt tags, and javascript
test for i.e. less than v5.5
Window.Opener.Document.getElementById("name").innerHTML - update problems
Inserting Multiple Records into MSaccess Database
How to find local user settings with Javascript
validate a textbox

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics