Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    762

    Dynamic contents box

    I found this code from http://www.dynamicdrive.com/dynamici...lapcontent.htm website im now trying to use it in my website

    this is the java script part that goes between <head></head> tag

    Code:
    <script type="text/javascript">
    function getposOffset(overlay, offsettype){
    var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
    var parentEl=overlay.offsetParent;
    while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }
    function overlay(curobj, subobj){
    if (document.getElementById){
    var subobj=document.getElementById(subobj)
    subobj.style.left=getposOffset(curobj, "left")+"px"
    subobj.style.top=getposOffset(curobj, "top")+"px"
    subobj.style.display="block"
    return false
    }
    else
    return true
    }
    function overlayclose(subobj){
    document.getElementById(subobj).style.display="none"
    }
    </script>
    to show the dynamic box, i have to link like this

    <a href="#" onClick="return overlay(this, 'subcontent')">Open Box</a>

    and the dynamic box it self is done like this:

    Code:
    <DIV id="subcontent1" style="position:absolute; display:none">
    // A table here
    </DIV>
    Everything works! but i just want a slight adjustment to the code. when i click on the link to open the box, it opens in the wrong area.

    For e.g. i click on the 'link' to open the box like this:
    http://img476.imageshack.us/img476/2701/shot14tt.jpg

    when the box opens, it opens in the wrong area like this:
    http://img476.imageshack.us/img476/1081/shot28zs.jpg

    What i want is to open like this:
    http://img455.imageshack.us/img455/293/shot30xj.jpg

    How do you do this????

  2. #2
    Join Date
    Aug 2005
    Posts
    454

Posting Permissions

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