View Full Version : how to run an event-triggered function from inside a HTML tag?

12-27-2005, 03:36 PM
when I call my "moveObject" function by an onMouseUp event handler like this:

document.onmouseup = function (e) {
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:

...<td onMouseUp="moveObject(e,testTable)">My text</td>...

This unfortunately doesn't work. Can You see the error??

Thanx Kozelnik

12-27-2005, 05:36 PM
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?

12-28-2005, 01:15 AM
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:

function moveObject(e,object) {
object.style.position = "absolute";
object.style.top = e.pageY;
object.style.left = e.pageX;

12-28-2005, 02:01 AM
onclick="moveObject(event, testTable)"