Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: onMouseMove

  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Location
    SC
    Posts
    936
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onMouseMove

    why doesnt this work in NS?

    <script>

    function followmouse(){

    document.getElementById('Trail').style.top = e.pageY
    document.getElementById('Trail').style.left = e.pageX
    }

    document.onmousemove=followmouse
    </script>
    <style>
    .Trail{
    position: absolute;
    top:0;
    left: 0;
    }
    </style>

    <body>
    <img src="Image.gif" id="Trail" class="Trail">
    Last edited by JAVAEOC; 01-15-2004 at 01:50 AM.

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Location
    Georgia
    Posts
    306
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onmousemove? followmouse function? never seen that used before, that code seems serously wrong somehow but if it works in other browsers beside netscape then try this...



    <head>
    <script>

    function followmouse()
    {
    document.getElementById('Trail').style.top = e.pageY
    document.getElementById('Trail').style.left = e.pageX
    }
    document.onMouseMove="followmouse"
    </script>
    <style type="text/css">
    .Trail{ position: absolute; top: 0; left: 0; }
    </style>
    </head>
    <body>
    <img src="Image.gif" id="Trail" class="Trail">
    ~Designer's Toolz~

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function followmouse(evt) {
    var n = document.getElementById('Trail');
    n.style.left = evt.pageX;
    n.style.top = evt.pageY;
    }
    document.onmousedown = followmouse;
    Hope that helps!

    Happy coding!

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, the reason it does not work has nothing to do with capitalization. All lower case is right.
    The reason it does not work in NS is that in IE the event object is global and therefore can be accessed from any function as you are doing. In Gecko, which follows the DOM2 Events, the event object is created for every event:

    document.onmousemove = function(e)
    { window.status = 'Mouse position: ' + e.pageX + ' : ' + e.pageY;
    }
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"


  •  

    Posting Permissions

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