smiffy
10-24-2005, 12:28 AM
Javascript is not my strongest of languages to say the least, but I want to be able to move a script out of the body section of a html page and place it in a .js script so that I can call it as a function from <img src="javascript:myfunction()" /> but I am missing that extra bit of code to make it work...
This is the script that is working in the body tag:
<script>
var day = new Date()
var hr = day.getHours()
if (hr < "9") {
document.write('<img src="images/closed_sign.gif" />')
}
else if (hr > "8")
if (hr < "18") {
document.write('<img src="images/open_sign.gif" />')
}
else if (hr > "17") {
document.write('<img src="images/closed_sign.gif" />')
}
</script>
The script basically shows a different image depending on the time of day.
I've tried:
function myfunction(){
var day = new Date()
var hr = day.getHours()
if (hr < "9") {
document.write('images/closed_sign.gif')
}
else if (hr > "8")
if (hr < "18") {
document.write('images/open_sign.gif')
}
else if (hr > "17") {
document.write('images/closed_sign.gif')
}
}
This just displays a blank page containing - images/closed_sign.gif
Anybody have any ideas?
This is the script that is working in the body tag:
<script>
var day = new Date()
var hr = day.getHours()
if (hr < "9") {
document.write('<img src="images/closed_sign.gif" />')
}
else if (hr > "8")
if (hr < "18") {
document.write('<img src="images/open_sign.gif" />')
}
else if (hr > "17") {
document.write('<img src="images/closed_sign.gif" />')
}
</script>
The script basically shows a different image depending on the time of day.
I've tried:
function myfunction(){
var day = new Date()
var hr = day.getHours()
if (hr < "9") {
document.write('images/closed_sign.gif')
}
else if (hr > "8")
if (hr < "18") {
document.write('images/open_sign.gif')
}
else if (hr > "17") {
document.write('images/closed_sign.gif')
}
}
This just displays a blank page containing - images/closed_sign.gif
Anybody have any ideas?