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

    Position of pop up layer

    I'm making a drop down style menu with all menu links using the same layer.
    However, I need to position the layer differently, depending on what link is clicked!

    My layer looks like this:
    <div id="details" name="details" style="position: absolute; width: 250px; height: 75px; visibility: hidden; background-color: black; color: white; font-family: verdana; font-size: 10px">
    Details!
    </div>

    How can get the X and Y coordinates of the link so I can set the div's TOP and LEFT to show it on the right place?

    Thanks
    Gustaf

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The following will move your layer.

    ID, X, and Y positions are passed to the function via the link



    <script>
    function show(id,X,Y){
    document.getElementById(id).style.pixelLeft=X
    document.getElementById(id).style.pixelTop=Y
    }
    </script>

    <a href="javascript:show('details',100,100)">Link 1</a>
    <a href="javascript:show('details',100,200)">Link2</a>


  • #3
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks,
    but I see now that my question was badly formed.
    Links are from a database-generated list, I don't know the coordinated.
    That's the real problem, I know how to position the layer - but I don't know how to get the coordinates of the link.


  •  

    Posting Permissions

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