SMF Version : 2.0.5
Problem : I have made javascript code, and I implement it to my theme ( Vivanto ), but it isn't working! So, help me :)
JS Code :
<script type="text/javascript">
var body = document.getElementById("header");
var datum = new Date();
var vreme = datum.getHours();
if(vreme >= 7)
{
body.style.backgroundImage = "url("../images/custom/dnevna.jpg")";
}
else if(vreme >= 19)
{
body.style.backgroundImage = "url("../images/custom/nocna.jpg")";
}
</script>
Thanks very much !
Have a read of this topic - a very similar request and a very similar resolution (regarding the use of quotes):
http://www.simplemachines.org/community/index.php?topic=512655

For future reference... When you post, asking for help, saying "It isn't working" isn't, really, terribly useful.
If you're getting errors, please tell us what the errors are. The more information that you can give us, the better chance we have of helping you. :)
i suspect "url("../images/custom/dnevna.jpg")" and its brother to be the culprits...
note the double quotes positions, try to replace the inner " by \' (escaped since they are probably outputted through an echo).
Nah, there's other quotes there that should be fine.
Seems to me the problem is the pathing; given the situation where this is called, I'd argue it shouldn't have the ../ at the start.
What happens between the hours of 0 and 6? Consider
else if(vreme >= 19 || vreme < 7)
The " inside of a "-delimited string should certainly be a problem -- as mentioned before, change the inner to ' (\' if the whole thing is output with ' delimiting).
Lainaus käyttäjältä: Arantor - lokakuu 18, 2013, 08:01:17 AP
Nah, there's other quotes there that should be fine.
Seems to me the problem is the pathing; given the situation where this is called, I'd argue it shouldn't have the ../ at the start.
Hummmm...
"string1"string2"string3" won't cut it in JS. He uses the same string delimiters for both the JS string AND the url() content string, it won't work. He may drop the inner " or replace them by \' or \" but keeping the " for the inner string won't work.
You'll get a "SyntaxError: Unexpected token ." for sure.
Oh, I see what you're getting at now. The fact the URL's almost certainly wrong is just a bonus. (In my defence I'd only been up 10 minutes when I saw this earlier, not awake yet)