How to I stop webpage scrolling via Javascript?

Posted on 2007-10-02
Last Modified: 2013-11-19
I've created an Interstitial Ad in Javascript that uses CSS layers to display an external web page, enclosed around a border.  But the problem I am having; is that if the underlying webpage is longer / taller than a the browser window; when scrolling the layered external website; and reaching the end it will start scrolling the underlying web page; thus pushing the layered web page away...

How can I prevent the underlying webpage from scrolling?  

This is all done in Javascript by the way, with an included JS file.

Question by:adworldmedia
    LVL 30

    Expert Comment

    could you show an example?

    you can hide the scrollbars on the containing element (eg. div) by setting overflow:hidden;

    which can be set in javascript as

    document.getElementByID('myDiv').style.overflow = 'hidden';

    Author Comment

    Unfortunately I don't have any examples that are "safe for work"...

    Basically I think all I need is something to prevent scrolling on a webpage itself.  I've done it before i just can't remember :)

    Accepted Solution

    I found the solution in a third party script:


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now