The problem is im trying to set up a different CSS on the different month but it doesnt work
can someone help me out i need help on this
ID:183791
![]() Apr 13 2007, 5:40 pm
|
|
This isn't for your Member blog, is it? Because you can't put Javascript in your Member blog.
|
Bump
and i've retabbed it so it's easier to read i really need help <script type="text/javascript"> var a = new Date() var b = a.getMonth() var e = a.getDate() var f = csss function CSSchoice(csss) { if (b == 1) { if (e == 1) { csss = Febuary.css } else { csss = Origanal.css } else { csss = Origanal.css } } } var g = csss var txt2 = "<link href=\'"+ g +"\' rel=\'stylesheet\' type=\'text/css\'>" document.write(txt2) </script> </body onLoad="CSSchoice()"> |
Now that you've made the code readable, the problems are actually pretty easy to spot.
1. You've wrapped up everything in a function that is never called, just defined - and even if it was called, your use of scope is all over the place so it wouldn't do anything anyway. You don't need it to be a function. Just kill these lines: function CSSchoice(csss) { And the matching closing brace as well. Also, this line does nothing: var f = csss. Get rid of that too. 2. The names of the files need to be enclosed in double quotes, since they're strings: "February.css", "Original.css" 3. I don't think you need to escape the single quotes like that, since they're in a double-quoted string. |
<HTML> |
You have a closing brace in the wrong place.
Also, you don't need the g var at all. You already have csss, so just use it instead. Fixed version: if (b == 1) |
Hiead