PDA

View Full Version : night loads index2 daytime loads index1



llr
01-29-2009, 05:24 AM
1) Script Title: Day & night script

2) Script URL (on DD): not available (http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm)

3) Describe problem: i know how to read javascript, but only when i see it :-(

I'd really like a script that reads the computers time when the index is loaded and redirects to index1 @daytime and to index2 @night and can easily be changed depending on how early it gets dark

The only script i've ever made is this css stylesheetchanger based on resolution check:


<script type="text/javascript" language=JavaScript>
if (screen.width>1599)
document.write('<link rel="stylesheet" type="text/css" href="../../../css/ie1600standaard.css">');
if (screen.width<1281)
document.write('<link rel="stylesheet" type="text/css" href="../../../css/ie1280standaard.css">');
if (screen.width<1025)
document.write('<link rel="stylesheet" type="text/css" href="../../../css/ie1024standaard.css">');
</SCRIPT>


I was thinking i need about the same thing with a clock and the
<link rel="stylesheet" type="text/css" href="../../../css/xxx.css">

replaced bij


window.location = "http://www.starthemel.nl/index1"

window.location = "http://www.starthemel.nl/index2"
depending on the time.

Can anyone please help me out?

llr
01-29-2009, 05:37 AM
I can't believe it, but i actually found it:


<script language="JavaScript">
<!--
var now = new Date( );
var hour = now.getHours( );
if (hour >= 7 && hour <= 20) {
window.location = "http://www.example.nl/day"}
else {
window.location = "http://www.example.nl/night"}
//-->
</script>