aquaben Posted August 26, 2010 Share Posted August 26, 2010 Hey I'm just wondering if there si a possiblility to get a different background automaticly change either per day or time of day like we can with writting?Example with writting:<script type="text/javascript">var d = new Date();theDay=d.getDay();switch (theDay){case 5: document.write(<b>Today is Friday</b>"); break; case 6: document.write(<b>today is Saturday</b>);break; }</script> Link to comment Share on other sites More sharing options...
Ingolme Posted August 26, 2010 Share Posted August 26, 2010 If it's just document.write(), you can write whatever you want to. document.write('<div style="background-color: blue"></div>'); I'd recommend a server-side language for this task, though. Link to comment Share on other sites More sharing options...
aquaben Posted August 26, 2010 Author Share Posted August 26, 2010 If it's just document.write(), you can write whatever you want to.document.write('<div style="background-color: blue"></div>'); I'd recommend a server-side language for this task, though. Ok I'll admit im a noob (again lol ) could you explain what a server-side language? Link to comment Share on other sites More sharing options...
MrFish Posted August 26, 2010 Share Posted August 26, 2010 I actually wouldn't do it like that, personally. Seems like it would get messy trying to put all of the information inside that div. I would just do this- <body> ...stuff</body> .....case 5: document.body.style.background = "images/friday.jpg";break;case 6: document.body.style.bgColor = "#FF000000"; //Redbreak;..... EDIT:Or if you are using images and really smart do this- document.body.style.background = "images/background" + theDay + ".jpg"; and have images like background1.jpg, background2.jpg, etc...Serverside script: PHP is an example. Javascript is executed on the visitors computer. PHP is executed on the website's server. Link to comment Share on other sites More sharing options...
thescientist Posted August 26, 2010 Share Posted August 26, 2010 Ok I'll admit im a noob (again lol ) could you explain what a server-side language?server-side language is exactly what it sounds like. It is code (scripts) that execute on the server. Javascript runs in the clients browser window, so it could be referred to as a client-side script. The magic of dynamic webpages is getting the two to talk to each other.you can read all about Javascript, PHP/SQL, and AJAX in the w3schools tutorials. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.