Results 1 to 5 of 5

Thread: when show layer no scrolling main page

  1. #1
    Join Date
    May 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default when show layer no scrolling main page

    Hello,
    I'm making a portfolio site for my photo's and stuggeling with a layer. I managed to modify it to my likings a whole lot with help from people, i'm not very good with java at all. As far as i came, there is still one thing that i would like to add to this script.

    When the layer is shown, i would like the scrollbar on the right of the main page (where the layer is inbedded) to be gone (no scrolling). If the layer is hidden (by klicking the link to do so) the scrollbar is back.

    The code from the show/hide layer goes in <head>;
    Code:
    <script type="text/javascript">
    <!--
    function toggleBox(szDivID, iState) // 1 visible, 0 hidden
    {
        if(document.layers)	   //NN4+
        {
           document.layers[szDivID].visibility = iState ? "show" : "hide";
        }
        else if(document.getElementById)	  //gecko(NN6) + IE 5+
        {
            var obj = document.getElementById(szDivID);
            obj.style.visibility = iState ? "visible" : "hidden";
        }
        else if(document.all)	// IE 4
        {
            document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
        }
    }
    // -->
    </script>
    Code that goes in body;
    Code:
    <div ID="demodiv" class="demo">there is a lot in here but i will spare you guys.</div>
    and the links that show/hide the layer;
    <a href="#" onClick="toggleBox('demodiv',0);" value="Hide Div">[x]</a>
    <a href="#" onClick="toggleBox('demodiv',1);" value="Show Div">show</a>

    the site; http://www.greyburn.net
    I really hope someone is a genius
    Thank you!
    Last edited by imogeen; 05-09-2007 at 07:50 PM. Reason: forgot link to site

  2. #2
    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

    I only know how to do this in modern browsers (gecko(NN6) + IE 5+). It may only be able to be done in modern browsers. And, it varies, how it is done by DOCTYPE. Since you are using no DOCTYPE, you could do it like so:

    Code:
        else if(document.getElementById)	  //gecko(NN6) + IE 5+
        {
            var obj = document.getElementById(szDivID);
            obj.style.visibility = iState ? "visible" : "hidden";
            if(document.getElementsByTagName)
            document.getElementsByTagName('body')[0].style.overflow = iState ? 'hidden' : (window.opera? 'inherit' : '');
        }
    If you were to use a DOCTYPE that turns on standards or almost standards mode, use 'html' instead of 'body'.
    - John
    ________________________

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

  3. #3
    Join Date
    May 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Aaah yes, great! This works, but only when i close the layer and open it again. The layer is visible (loaded?) from the start, and then still the scroll is there.

    Here you can see your script add working; http://www.greyburn.net
    Is there a way to also get rid of the scroll at start of page?

  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

    Code:
    <script type="text/javascript">
    <!--
    if(document.getElementsByTagName)
    onload=function(){
    document.getElementsByTagName('body')[0].style.overflow = 'hidden';
    };
    function toggleBox(szDivID, iState) // 1 visible, 0 hidden
    {
        if(document.layers)	   //NN4+
        {
           document.lay . . .
    - John
    ________________________

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

  5. #5
    Join Date
    May 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Excellent! Thank's alot

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
  •