reposition DIV element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nospam

    reposition DIV element

    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="JavaS cript">
    <![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.offset Top + 120;
    eLeft = myTarget.offset Left;
    }

    var IE = document.all?tr ue:false
    if (!IE) document.captur eEvents(Event.M OUSEMOVE)

    document.onmous emove = getMouseXY;
    document.onmous edown = getMouseXY;

    var tempX = 0
    var tempY = 0

    function getMouseXY(e)
    {
    if (IE)
    {
    tempX = event.clientX + document.body.s crollLeft
    tempY = event.clientY + document.body.s crollTop
    }
    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="adminrig ht">
    <tr>
    <xsl:attribut e name="onclick">
    getPos(event);
    with (document.getEl ementById("admi nRight"))
    {
    style.Top=eTop;
    style.width="63 0px";
    style.position= 'absolute';
    style.backgroun d='#FFF';
    style.display=' block';
    }
    </xsl:attribute>
    </tr>


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Martin Honnen

    #2
    Re: reposition DIV element



    nospam wrote:
    [color=blue]
    > getPos(event);
    > with (document.getEl ementById("admi nRight"))
    > {
    > style.Top=eTop;[/color]

    Try
    style.top = eTop + 'px';



    --

    Martin Honnen

    Comment

    • nospam

      #3
      Re: reposition DIV element

      Thanks for the reply. I did that and it still doesn't move the <DIV> to
      the row where the mouse is clicked.




      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Martin Honnen

        #4
        Re: reposition DIV element



        nospam wrote:
        [color=blue]
        > I did that and it still doesn't move the <DIV> to
        > the row where the mouse is clicked.[/color]

        Show us the relevant HTML and script and perhaps we can help further but
        get rid of the XSLT before posting the code.

        --

        Martin Honnen

        Comment

        Working...