Results 1 to 2 of 2

Thread: Javascript movement

  1. #1

    Javascript movement

    I wrote the following code to move text around the screen in javascript and i can't figure out what is wrong with it... can someone help?

    <HTML>
    <HEAD>
    <TITLE>
    Movement
    </TITLE>
    <script language = "javascript">
    firstTime = true;
    function moveIt()
    {
    if (firstTime)
    {
    document.all.mover.style.pixelTop = 5
    firstTime = false
    }

    document.all.mover.style.pixelTop += 5


    setTimeout("moveIt()", 20)
    }
    </script>
    </HEAD>
    <BODY onLoad = "MoveIt()">
    <DIV ID = "mover" STYLE = "POSITION: ABSOLUTE; LEFT: 5PX; TOP: 5PX;">
    <P>
    Hello, World!!!
    </P>
    </DIV>
    </BODY>
    </HTML>

    Thanks in advance
    You laugh because im different, i laugh because your all the same.

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    kryptonite0110, surprisingly enough, function name is case sensitive (I just knew it myself *).

    So try to change all reference to "MoveIt()" to the same case and reload the page. Note that you need to tell the browser when to stop, since your javascript will move the "Hello, World" text down continuously.

    *) What I did was loading the page in Mozilla and type javascript: in the location bar, which displayed "Error: MoveIt is not defined in the JavaScript console. Then I changed the all "MoveIt()" to the same case, and reload the page. It still didn't move the text and I expected that, since the HTML doc is designed to run ONLY in IE (it uses document.all - IE proprietary). Mozilla's JavaScript console also confirmed that. But now it's safe to load it in IE and it works properly.

    BTW, does anybody know if there is similar JavaScript console in IE and how to open it?

    Peace always,
    <jdenny>
    Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
    I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •