...

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



Capone
12-08-2006, 03: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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Msource</title>
<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">
<!--
pickCSS();
//-->
</script>
</head>

Any assisstance would be greatly appreciated.:confused:

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

_Aerospace_Eng_
12-08-2006, 05: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).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum