Connecting Tech Pros Worldwide Forums | Help | Site Map

Div tag moving script onmouseover not working in netscape and firefox

Newbie
 
Join Date: Sep 2007
Posts: 8
#1: Sep 7 '07
Hello All

I built a simple script to move a div tag with a MouseOver event handler. This worked fine in Safari but would not work in Netscape and Firefox

Can anyone help?

You can see it working in Safari on
http://observationist.co.uk

So far this is what I have

Expand|Select|Wrap|Line Numbers
  1. function moving(id){
  2. if (document.getElementById("slider").style.left<10000)
  3. document.getElementById("slider").style.left-=5
  4. moveid = window.setTimeout(moving, 5000, true);
  5. }
  6.  
  7. function stop(){
  8. window.clearTimeout(moveid);
  9. }
  10.  
  11. function moving2(){
  12. if (document.getElementById("slider").style.left<10000)
  13. document.getElementById("slider").style.left+=5
  14. moveid2 = window.setTimeout(moving2, 50, true);
  15.  
  16. }
  17. function stop2(){
  18. window.clearTimeout(moveid2);
  19. }

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Sep 7 '07

re: Div tag moving script onmouseover not working in netscape and firefox


Please remember to use code tags when posting code.

You need to specify the values as a measurement, e.g. "px".

PS. changed the thread title too.
Newbie
 
Join Date: Sep 2007
Posts: 8
#3: Sep 7 '07

re: Div tag moving script onmouseover not working in netscape and firefox


Oh dear I seem to be getting even asking the question wrong !! Help with the answer would be appreciated if anyone actually knows about this stuff.

I have had a couple of suggestions but non which actually work. When giving a suggestion maybe it would be good practice to TEST the thing first before assuming you know the answer ???!!!

This would save lots of space on this site and mean that maybe you learn something too.

I have no idea what is wrong here but have tried a couple of peoples suggestons mostly with regard the the declaration of the px withing the code but this has no effect. The answer is more subtle or more obvious than that it would seem.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Sep 7 '07

re: Div tag moving script onmouseover not working in netscape and firefox


Quote:

Originally Posted by cjparis

I have had a couple of suggestions but non which actually work. When giving a suggestion maybe it would be good practice to TEST the thing first before assuming you know the answer ???!!!

It would also be good practice to have faith in some of the suggestions! Try adapting this:
Expand|Select|Wrap|Line Numbers
  1. function moving(){
  2.       var left =
  3. parseInt(document.getElementById("slider").style.left);
  4.       if (left <10000)
  5.       document.getElementById("slider").style.left=(left-5) + "px";
  6.       moveid = window.setTimeout("moving()", 1000);
  7. }
  8.  
Reply