Results 1 to 7 of 7

Thread: Overlapping Content link

  1. #1
    Join Date
    Nov 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Overlapping Content link

    Script: Overlapping Content link
    http://www.dynamicdrive.com/dynamici...lapcontent.htm

    Very useful script. I was wondering how to do two things:

    1) When a link is clicked, close any other content that may be open
    2) Make sure it fits within the viewable screen area

    Thanks for any help.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format for asking a question.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Nov 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    man you are fast Twey

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    For number one, change this:
    Code:
    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
    }
    to this:
    Code:
    function overlay(curobj, subobj){
    if (document.getElementById){
    var overlays=document.getElementsByTagName('div')
    for (var i_tem = 0; i_tem < overlays.length; i_tem++)
    if (overlays[i_tem].id.indexOf('subcontent')!==-1)
    overlays[i_tem].style.display="none"
    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
    }
    For number two, there are various methods to do something like this but, all that I have seen suffer from the possibility that the window will be limited in two or three dimensions rather than the expected one. This gives rise to all sorts of weird effects. A better approach would be to keep the size of the overlays reasonable and to keep their trigger elements high enough on the page that a reasonable window size will accommodate their full visibility. If you are trying to make this script into a menu or tooltip, don't. Use a menu or tooltip script for that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks but still not working

    thanks so much for replying, bur for some reason, the previous overlay isn't closing when a new one is clicked...

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Is its id subcontentX where x is a number or simply subcontent? The id's must be as laid out as in the demo for this modification to work. I tried this out here, and it worked fine. So, if the id is not the trouble, post a link to your page and I'll see what's stopping it from working.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Nov 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John, thanks for the response. With the help of a friend, I modified the script as below and it works great. Thanks for the help.

    -----------------------------

    Add class="OverlayDiv" to all divs that are overlay...

    <DIV id="subcontent" style="position:absolute; display:none" class="OverlayDiv">
    ...
    ...
    <DIV id="subcontent2" style="position:absolute; display:none" class="OverlayDiv">
    ...
    ...

    and change

    function overlay(curobj, subobj)

    to

    function overlay(curobj, subobj){
    if (document.getElementById){
    closealloverlay();
    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
    }

    and add

    function closealloverlay()
    {
    var oDivs = document.getElementsByTagName("DIV");
    var i;

    for (i = 0 ; i < oDivs.length ; i++)
    {
    if (oDivs[i].className == "OverlayDiv")
    {
    overlayclose(oDivs[i].id);
    }
    }
    }

Bookmarks

Posting Permissions

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