|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (8 bit)
Join Date: Jun 2004
Posts: 220
|
Javascript Not Displaying
On my website, I would like to use javascript to display the following:
"Happy [Day of week] and good [time of day], folks." For example, if it were a Monday morning, it should output: "Happy Monday and good morning, folks." Here is the code I have been unsuccessfully using: HTML Code:
<script type="text/javascript"> var d=new Date() var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") document.write("Happy " + weekday[d.getDay()] + " and ") var time = d.getHours() if (time < 12) { document.write("good morning") } else if (time > 12 & time < 17) { document.write("good afternoon") } else { document.write("good evening") } document.write(", folks.") </script> |
|
|
|
|
|
#2 |
|
Moderator
Staff
Premium Member
Join Date: Aug 2003
Location: Richmond, VA
Posts: 7,835
|
It's working fine here, at least in MSIE. I'm presuming you're all writing this within the body tags.
kram
__________________
"For today, goodbye. For tomorrow, good luck. And forever, Go Blue!"
University of Michigan President Mary Sue Coleman |
|
|
|
|
|
#3 |
|
Member (8 bit)
Join Date: Jun 2004
Posts: 220
|
Okay, that coding actually works for me too.
I changed the less than signs to actual signs, rather than "<" and also changed the greater than signs to actual signs, rather than ">" for my post. How come these character references aren't working? It seems the corresponding entity references aren't working as well (">" and "<"). I am working in an XHTML 1.1 document, and W3C is cautioning me about using the raw "<" and ">" symbols. Suggestions? EDIT: Looks like this post isn't displaying things as I wanted it too. In my document, when I use (this will all be written out, so it doesn't get changed) ampersand, letter g, letter t, semicolon, to express a ">" symbol, rather than just using my keyboard, and pressing shift+, I tried both character references and entity references in my code for my page, none of which work in Firefox. See this page. Last edited by TennBikeBerk; 07-20-2005 at 10:19 PM. |
|
|
|
|
|
#4 | |
|
Moderator
Staff
Premium Member
Join Date: Aug 2003
Location: Richmond, VA
Posts: 7,835
|
Quote:
kram |
|
|
|
|
|
|
#5 | |
|
Staff
Premium Member
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
|
Quote:
__________________
Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row |
|
|
|
|
|
|
#6 | |
|
Member (8 bit)
Join Date: Jun 2004
Posts: 220
|
I suppose I could just the raw symbols, since it is part of the coding. I do not need them to display as a part of a document.write.
Just as a note, it does work when I use the raw symbols, but when I use W3C's XHTML 1.1 validator, it says the page is valid, but I receive the following: Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|