View Full Version : Problem linking HTML to 2 Different CSS Style Sheets

12-08-2006, 04:22 PM
I am having difficulty finding in the forum information that relates specifically to what I am trying to attempt.

I have two CSS style sheets created. One obviously works cause everything is being styled and the other one isnt. I am not sure why this is or wondering if I missed something or typed something incorrectly.

One style sheet is for IE and the other one is for firefox.

This is the code I put in my JavaScript .js file

function pickCSS() {
var browsername = navigator.appName;
if(browsername=="Microsoft Internet Explorer") {
document.write("<link rel='stylesheet' href='explorercss.css' type='text/css'>");
else if(browsername=="Mozilla") {
document.write("<link rel='stylesheet' href='mycss.css' type='text/css'>");

This is the code at the top of my HTML file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="mycss.css" rel="stylesheet" type="text/css" />
<link href="explorercss.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="javascript1.js"></script>
<script type="text/JavaScript">

Any assisstance would be greatly appreciated.:confused:

12-08-2006, 04:45 PM
forget it... Once I put Netscape instead of Mozilla it worked fine.

12-08-2006, 06:37 PM
Using javascript to configure user styles is a bad idea. JS can be disabled. You are better off using conditional comments (http://www.quirksmode.org/css/condcom.html).