0

Hey. I am new to webprogramming..so sorry if this question sounds stupid:D
I just wanted to make an animation but in firefox that animation just doesnt appear tho it works great in IE and opera. Do you have any idea what's wrong? I use the function setTimeout() and document.all[id].style...etc to take the value I need. No error but no animation as well=\

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kracko
1

You will have to post the code.

BTW: document.all is deprecated at best and unsupported at worst; use document.getElementById('x') instead.

0

aw well my code was very complicated..jst help me with this one i will figure out with mine

<input type="button" onclick="move()" value="go" />
<br />
<img src="btn16.gif" style=" position:absolute; height:100px; width:100px; top:20px" id="img" />
<script>
var k=0;
function move(){
var t=document.getElementById("img").style.top;
t=parseInt(t);
t+=15;
document.getElementById("img").style.top=t;
if(k<10){
k++;
setTimeout("move()",1);
}
}
</script>
1

This

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <title></title>
  </head>
  <body>
    <form>
      <input type="button" onclick="mve()" value="go"><br>
    </form>
    <img src="btn16.gif" style="position:relative; height:100px; width:100px; top:0px" id="img" name="img"> 

<script type="text/javascript">

var oImg = document.getElementById("img")
var t = parseInt(oImg.style.top)
var k = 0;

function mve() {
    t += 15;
    oImg.style.top = t + 'px'
    if (k++ < 10) { setTimeout("mve()", 100); }
}

</script>
  </body>
</html>

works fine here in all browsers.

Note: if you set the timeout to a small number [like 1] and your machine is fast enough, the image will appear to jump instead of sliding.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.