PDA

View Full Version : Altering a script to access external file?


alienyouthct
02-09-2003, 09:10 PM
I believe I got the Javascript from JavaScriptKit (my memory stinks), and it can change the color of your page's background depending on the hour. I wanted to modify it so that I can call from an external source file. What I was hoping to do was design a day layout, and a night layout, for my page. This way, I would just be able to put the script on every page, link it to the same files, and have it change automaticlaly. Any suggestions?

var now = new Date();
var hours = now.getHours();
var psj=0;

//18-19 night
if (hours > 8 && hours < 20){
document.write('<body bgcolor="red" text="#FFFFFF">')
}


//22-4 night
if (hours > 21 || hours < 8){
document.write('<body bgcolor="black" text="#FFFFFF">')
}

Unfortnuately, I can't figure out how to get document.write to insert the entire contents of a file yet...

arnyinc
02-09-2003, 09:20 PM
Maybe you could have two different style sheets and use one of them depending on the time. I'm not sure how to do that in javascript though.