I know this has been done and done, but I didn't see anyone address my specific question. What I want to do is to built my css on the fly. Is that at all possible? Right now, I use a js to direct to one of 5 css files. It works okay, but every time I need to add a new style, I have to do it 5 times. Here's what I have right now:
<!-- default css -->
<link rel="stylesheet" type="text/css" href="0800.css">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (screen.width == 640) {
document.write('<link rel="stylesheet" type="text/css" href="style-0640.css">');
}
if (screen.width == 800) {
document.write('<link rel="stylesheet" type="text/css" href="style-0800.css">');
}
if (screen.width == 1024) {
document.write('<link rel="stylesheet" type="text/css" href="style-1024.css">');
}
if (screen.width == 1280) {
document.write('<link rel="stylesheet" type="text/css" href="style-1280.css">');
}
if (screen.width == 1600) {
document.write('<link rel="stylesheet" type="text/css" href="style-1600.css">');
}
// End -->
</script>
What I want to do is to build variables (mainly font sizes ) with the javascript and then plug those into the values into the styles and then not have an external call to the .css file. Since I only have one header file, it would be a lot less work than changing/adding to 5 style sheets every time I want to change something. Here are a few entries in my style sheet:
.txtBL12 { color: #000000; font-size: 12px; }
.txtMR12 { color: #660033; font-size: 12px; }
A.aBlMr12 { COLOR: #0000FF; text-decoration: none; font-size: 12px; }
A.aBlMr12:hover { COLOR: #660033; text-decoration: underline; }
So... is there any way to set a variable (say font size) in javascript and then use that in the style???