9 Replies - 7560 Views - Last Post: 12 June 2002 - 11:21 AM

#1 gitz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 02

Simple Javascript Animation

Posted 11 June 2002 - 06:57 PM

hi guys. i've been having trouble with a simple script. what i'm trying to do is get a pic to alternate it's src's back and forth, creating a simple animation. here's my code::






<img src="studio5.jpg" name="karse" border=0>
<script language="javascript">
function bang()
{
if (document.karse.src=='studio5.jpg')
{
document.karse.src="studio6.jpg"
document.write("works1")
}
if (document.karse.src=='studio6.jpg')
{
document.karse.src="studio5.jpg"
document.write("works2")
}
setTimeOut("bang()",100)
}
bang()
</script>
</body>

any help or suggestions on why this isnt working? thanks a lot.
-gitz-

Is This A Good Question/Topic? 0
  • +

Replies To: Simple Javascript Animation

#2 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: Simple Javascript Animation

Posted 11 June 2002 - 07:04 PM

ok, just something that i thought about, but doesn't the <script> tags and everything in between have to be in the head tag, and don't you have to call that javascript function in some manner in order for it to work?
Was This Post Helpful? 0
  • +
  • -

#3 gitz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 02

Re: Simple Javascript Animation

Posted 11 June 2002 - 07:07 PM

doesnt necessarily have to be in the head tags. and i'm calling it right after it's declared, before i close the </script>.
Was This Post Helpful? 0
  • +
  • -

#4 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: Simple Javascript Animation

Posted 11 June 2002 - 07:08 PM

ok, i get it, so maybe you can play around with this: example and get it to do what you need.
Was This Post Helpful? 0
  • +
  • -

#5 gitz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 02

Re: Simple Javascript Animation

Posted 12 June 2002 - 08:35 AM

awesome, thanks a lot man:-) i got just what i needed.
-gitz-
Was This Post Helpful? 0
  • +
  • -

#6 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: Simple Javascript Animation

Posted 12 June 2002 - 08:37 AM

not a problem, glad that i could help, and by the way, i'm a girl :pirate:
Was This Post Helpful? 0
  • +
  • -

#7 capty99  Icon User is offline

  • i am colt mccoy
  • member icon

Reputation: 98
  • View blog
  • Posts: 10,081
  • Joined: 26-April 01

Re: Simple Javascript Animation

Posted 12 June 2002 - 10:01 AM

yeah, well hes not the only one that didnt know that. ;)
Was This Post Helpful? 0
  • +
  • -

#8 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Simple Javascript Animation

Posted 12 June 2002 - 10:14 AM

capty you're just two short of 2000 posts!

We should have a P2K celebration :P
Was This Post Helpful? 0
  • +
  • -

#9


Reputation: 0

Re: Simple Javascript Animation

Posted 12 June 2002 - 11:20 AM

fyrestorm is a girl? Who woulda thunk it...

everyone knows girls can't code because their logic is whacked...

Hoopster
Was This Post Helpful? 0

#10 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Simple Javascript Animation

Posted 12 June 2002 - 11:21 AM

hey gitz,

Is there any reason you don't just use an animated gif?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1