Thursday, November 15, 2012

Answers > How Can I Change the Background of My Web Page Depending on the Time Only Using XHTML?

How Can I Change the Background of My Web Page Depending on the Time Only Using XHTML?

by nForms on April 14, 2012

I need to change the background of my web page 3 times a day. good morning, good afternoon, and good evening. this has to be in xhtml and not use javascript or PHP. I have to do this for a class which is why I cant use these.

Tags: , , , , , ,

Similar XForms | XML Posts

{ 1 comment… read it below or add one }

Tomm April 4, 2011 at 9:36 am

<script language="JavaScript">

day=new Date() //..get the date

x=day.getHours() //..get the hour

if(x>=0 && x<4) {

document.write(‘<style type="text/css">body{background: white url(1st.jpg); color: black}"></style>’)

} else

if(x>=4 && x<12) {

document.write(‘<style type="text/css">body{background: white url(2nd.jpg); color: black}</style>’)

} else

if(x>=12 && x<18) {

document.write(‘<style type="text/css">body{background: white url(3rd.jpg); color: black}</style>’)

} else

if (x>=18 && x<24) {

document.write(‘<style type="text/css">body{background: white url(4th.jpg); color: black}</style>’)

}

</script>

Previous post:

Next post: