Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
skot:317 #1
swapping image with getHours()
I want to swap images in a div using javascript getHours(). I've done it in
Flash and it worked fine, yet it doesn't seem to here.
Here's the code I have:
<div id="logo" style="margin:5px 0 0
5px;height:200px;width:200px;cursor:pointer">
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
var dt:Date=new Date();
var hour=dt.getHours();
if (hour>=6 && hour<=14){
document.write("<img src=logo1.jpg'>")
} else
if (hour>=14 && hour<=16){
document.write("<img src='logo2.jpg'>")
} else
if (hour>=16 && hour<=20){
document.write("<img src='logo3.jpg'>")
} else
if ((hour>=20 && hour<=23) || (hour>=0 && hour<=6)){
document.write("<img src='logo4.jpg'>")
} else {
document.write("<img src='logo1.jpg'>")
}
// -->
</SCRIPT>
</div>
skot:317 Guest
-
image swapping urgent
hi all need help with image swapping. its perfectly working in my system offline as well as online. but its not showing the image in other... -
need help with image swapping.
hi all need help with image swapping. its perfectly working in my system offline as well as online. but its not showing the image in other... -
text and image swapping
Hi Guys, returning to Director after a long while. My memory has faded on me so I hope that you will give me a hand! I need to create a... -
image swapping in php
"Richard" <anom@anom> schrieb im Newsbeitrag news:bm50kc0sgn@enews2.newsguy.com... You can't do that. A mouseover event is processed at the... -
Image Swapping (Not Rollover)
I have an online portfolio to display my photography work, and on one page i have a list on the left, and i have the photographs on the right, i want... -
T.Pastrana - 4Level #2
Re: swapping image with getHours()
You have an invalid var declaration. You can't use the semicolon in a var :
var dt:Date=new Date();
should be ... var dt=new Date();
There's also an error in your first image.. It's missing the first ' in the
img src.
document.write("<img src=logo1.jpg'>")
should be ... document.write("<img src='logo1.jpg'>")
--
Regards,
...Trent Pastrana
[url]www.fourlevel.com[/url]
Dreamweaver Designer Tools
iFrameSuite | MiniMenus | Scroller Packages | More...
-----------------------------
"skot:317" <webforumsuser@macromedia.com> wrote in message
news:dap54t$eae$1@forums.macromedia.com...>I want to swap images in a div using javascript getHours(). I've done it in
> Flash and it worked fine, yet it doesn't seem to here.
> Here's the code I have:
>
>
>
> <div id="logo" style="margin:5px 0 0
> 5px;height:200px;width:200px;cursor:pointer">
> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
> <!--
> var dt:Date=new Date();
> var hour=dt.getHours();
> if (hour>=6 && hour<=14){
> document.write("<img src=logo1.jpg'>")
> } else
> if (hour>=14 && hour<=16){
> document.write("<img src='logo2.jpg'>")
> } else
> if (hour>=16 && hour<=20){
> document.write("<img src='logo3.jpg'>")
> } else
> if ((hour>=20 && hour<=23) || (hour>=0 && hour<=6)){
> document.write("<img src='logo4.jpg'>")
> } else {
> document.write("<img src='logo1.jpg'>")
> }
> // -->
> </SCRIPT>
> </div>
>
T.Pastrana - 4Level Guest
-
skot:317 #3
Re: swapping image with getHours()
You are right, it was the :Date that was not correct.
Thanks!
skot:317 Guest



Reply With Quote

