Hello all
I'm trying to find code to display different content depending on the day. I'd appreciate any direction. Thanks!
Hello all
I'm trying to find code to display different content depending on the day. I'd appreciate any direction. Thanks!
edit
Displays content by the clock on your pcCode:<html> <head> <script> onload=function() { var content = new Array("sunday content","monday content","tuesday content","wednesday content","thurday content","friday content","saturday content") var date = new Date() var day = date.getDay() var obj = document.getElementById("output") obj.innerHTML=content[day] } </script> </head> <body> <div id="output"></div> </body> </html>
Last edited by mburt; 08-01-2006 at 04:38 PM.
- Mike
Perfect! Can the new Array hold html code?
Yes, but you'll have to use escape characters.
Ex:
every time you need to use " type a backslash before it, like this: \"Code:var content = new Array("sunday content,"monday content","<font color=\"red\"><i>tuesday content</i></font>","wednesday content","thurday content","friday content","saturday content")
- Mike
Simpler:Code:<script type="text/javascript"> window.onload = function() { var today = (new Date()).getDay(); for(var i = 1, e; e = document.getElementById("day" + i + "content"); ++i) if(i - 1 != today) daycontent.style.display = "none"; }; </script> <div id="day1content"> Sunday's Content </div> <div id="day2content"> Monday's Content </div> <div id="day3content"> Tuesday's Content </div> <!-- ... and so on, to day7content. -->
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Umm.. That won't work in Mozilla
- Mike
Bookmarks