...

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



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


<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:


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

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

Thanx Kozelnik

Kor
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?

ottus
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;
};

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum