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
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to run an event-triggered function from inside a HTML tag?

    Hello,
    when I call my "moveObject" function by an onMouseUp event handler like this:

    Code:
    <script>
    document.onmouseup = function (e) {
    moveObject(e,testTable);
    };
    </script>
    everything works fine. But I would like to call that function not by clicking anywhere in the document, but by clicking on a table clell. I used this:
    Code:
    ...<td onMouseUp="moveObject(e,testTable)">My text</td>...
    This unfortunately doesn't work. Can You see the error??

    Thanx Kozelnik

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    everything works fine
    not for all browsers, anyway

    What is, in fact, yout final goal? You want do attach dynamically an event to an object?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. I want my function "moveObject" to be executed by clicking on a specific cell in a table. The function moves another table to the same position as the mouse cursor. The function script is:
    Code:
    function moveObject(e,object) {
    	object.style.position = "absolute";
    	object.style.top = e.pageY;
    	object.style.left = e.pageX;
    };

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    onclick="moveObject(event, testTable)"


  •  

    Posting Permissions

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