disable scrollbars on parent window

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

disable scrollbars on parent window

SeeDoubleYou
I thought of some functionality to disable the scrollbars of the parent window when opening a shadowbox. This can be useful in some cases. Unfortunately, IE is once again in the way. What I did was the following. I have A function called during the onOpen doing the following
bodyDefaultPostitionValue = document.body.style.position;
bodyDefaultOverflowValue = document.body.style.overflow;
document.body.style.position = "relative";
document.body.style.overflow = "hidden";
the default values are stored (var is declared elsewhere in the file). This disables the scrollbars. Then in the onClose we have to reset the default values like so:
document.body.style.overflow = bodyDefaultOverflowValue;
document.body.style.position = bodyDefaultPostitionValue;
This works very nice in FF, Chrome, IE8, but in IE7 the scrollbars do disappear, but the page scrolls to the top as well which is unwanted functionality. I've been trying lots of things to fix this but remain unsuccessful so far. In a cry for help I turn to you my fellow shadowboxonians, to find the answer to to the ultimate question of life, the univ... wait, lets not overdo it, just help me please if you have a clue on how to fix this. Thanks in advance!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

mjijackson
Administrator
Shadowbox is designed to never overflow the viewport, so you should never have the scrollbars anyways. No need for an elaborate hack.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

SeeDoubleYou
I guess you missed my point. What I am talking about is that when shadowbox open on a page that has scrollbars (so the parentwindow), then I want those scrollbars disabled. For example the shadowbox-js homepage. When I click on a link that opens a shadowbox the shadowbox gets loaded, but after that I am still able to scroll the parent window up and down. This is what I would very much like to see disabled.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

mjijackson
Administrator
Why is that necessary? Shadowbox scrolls with the page (and resizes with the viewport) so you shouldn't ever have to mess with the parent window.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

SeeDoubleYou
It is necessary because it very annoying when the parent scrolls behind the shadowbox. But before getting into that discussion, do you think it is possible to disable the scrolling of the parent?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

SeeDoubleYou
Hmm, I'm shure  not to be the only one who would like to see this, anyone got a solution yet?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

kroche
I would like to have this ability. I am the person who codes the site with shadowbox and I still accidentally scroll the page when in the SB. It is rather annoying when you do that, and then you are on a different part of the page after you close the SB. It would be nice to have the ability to disable the scrolling, especially since most laptops, and mice in general, have scroll wheels.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

arttronics
In reply to this post by SeeDoubleYou
Instead of hiding the scrollbars, thus effecting IE's problem of going to the top of the page... you might want to temporarily disable the mouse wheel causing the scrolling function on the parent page. Use your favorite search engine and look up:

onMouseWheel=return(false)


The following website I Googled gives a couple of examples, and also to disable the Arrow Up and Down keys too:

thread216-1262956


When posting your markup here on the forum follow these simple steps:

0. Login and paste your markup into the Message Box.
1. Mouse select the markup you just pasted.
2. Press the More Button from the Message Box Toolbar.
3. Select Raw text from the drop down menu. DONE!

If I don't respond to your POST, it's your inability to provide your markup correctly.

Check out a few DEMOS I made that are here in this forum.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

tmparisi
I too, find this incredibly annoying, especially for the user.  Anyone ever get this working?

I tried adding the following to the parent window:

<script>
document.onmousewheel=function(){return false};
document.onkeydown=function(){return event.keyCode==38 || event.keyCode==40 ? false : true;}
</script>

Though it stops the user from scrolling inside the windows, the following are still problems:

1.  If the user scrolls down with the mouse wheel, inside the shadowbox, then the parent window will also scroll once the end of the shadowbox has been reached.

2.  How would this best be implemented so the code is only active when the shadowbox is open, and functionality is returned upon closing the shadowbox.

This is how I call my shadowbox:

<a href="https://www.website.com/machform/embed.php?id=8" rel="shadowbox;width=1100;height=950;player=iframe" class="button1"><span></span><strong>Click Here</strong></a>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

arttronics
The scenario:

A webpage containing a lot of content also has a vertical scrollbar to allow easily navigation of the webpage.

A Shadowbox iframe Player is shown and will always has a vertical scrollbar because the iframe page loads a lot of content as well.


The issue:

Scrolling inside Shadowbox iframe Player causes the webpage behind Shadowbox to scroll away from it's current location too.


Expected outcome:

Prevent the webpage that's behind Shadowbox to remain in place while scrolling inside the opened Shadowbox.


Working Solution:

    <script type="text/javascript">

        function SBopen() {
            document.body.style.overflow = "hidden";
        }

        function SBclose() {
            document.body.style.overflow = "auto";
        }

        Shadowbox.init({
            onOpen: SBopen,
            onClose: SBclose
        });

    </script>

Link and credit goes to: Ian Devlin

When posting your markup here on the forum follow these simple steps:

0. Login and paste your markup into the Message Box.
1. Mouse select the markup you just pasted.
2. Press the More Button from the Message Box Toolbar.
3. Select Raw text from the drop down menu. DONE!

If I don't respond to your POST, it's your inability to provide your markup correctly.

Check out a few DEMOS I made that are here in this forum.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

tmparisi
Brilliant!  Thank you very much!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

Dracked
In reply to this post by arttronics
Thank you so much for that. Brilliant, simple solution to an annoying problem.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: disable scrollbars on parent window

Alex
In reply to this post by arttronics
what file and what is the location where i can add this code? Please help
Loading...