G
Guest
I am tring to flow a DIV element to the position where a row in a table
is clicked. I use the following javascript to caculate the mouse
position. The X and Y of the mouse is calculated correctly, but the DIV
does not flow there. The DIV always anchors top left corner of the
table, no matter how many far down the row is clicked. Does anyone know
why? Thanks.
<xsl:template match="/">
<form>
....
<xsl:apply-templates select="/adminrights/adminright"/>
</form>
<script language="JavaScript">
<![CDATA[
var eTop, eLeft, myTarget; //page variables
var i=0; //page variables
function getPos(e)
{
if (!e) {e = window.event;}
else {myTarget = e.srcElement;}
eTop = myTarget.offsetTop + 120;
eLeft = myTarget.offsetLeft;
}
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
document.onmousedown = getMouseXY;
var tempX = 0
var tempY = 0
function getMouseXY(e)
{
if (IE)
{
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
}
else
{
tempX = e.pageX
tempY = e.pageY
}
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
return true
}
]]>
</script>
</xsl:template>
<xsl:template match="adminright">
<tr>
<xsl:attribute name="onclick">
getPos(event);
with (document.getElementById("adminRight"))
{
style.Top=eTop;
style.width="630px";
style.position='absolute';
style.background='#FFF';
style.display='block';
}
</xsl:attribute>
</tr>
is clicked. I use the following javascript to caculate the mouse
position. The X and Y of the mouse is calculated correctly, but the DIV
does not flow there. The DIV always anchors top left corner of the
table, no matter how many far down the row is clicked. Does anyone know
why? Thanks.
<xsl:template match="/">
<form>
....
<xsl:apply-templates select="/adminrights/adminright"/>
</form>
<script language="JavaScript">
<![CDATA[
var eTop, eLeft, myTarget; //page variables
var i=0; //page variables
function getPos(e)
{
if (!e) {e = window.event;}
else {myTarget = e.srcElement;}
eTop = myTarget.offsetTop + 120;
eLeft = myTarget.offsetLeft;
}
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
document.onmousedown = getMouseXY;
var tempX = 0
var tempY = 0
function getMouseXY(e)
{
if (IE)
{
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
}
else
{
tempX = e.pageX
tempY = e.pageY
}
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
return true
}
]]>
</script>
</xsl:template>
<xsl:template match="adminright">
<tr>
<xsl:attribute name="onclick">
getPos(event);
with (document.getElementById("adminRight"))
{
style.Top=eTop;
style.width="630px";
style.position='absolute';
style.background='#FFF';
style.display='block';
}
</xsl:attribute>
</tr>