How to disable scrolling the document body?

Posted by Manohar on Stack Overflow See other posts from Stack Overflow or by Manohar
Published on 2010-03-18T11:50:40Z Indexed on 2010/03/18 12:21 UTC
Read the original article Hit count: 477

Filed under:
|
|
|

I have a HTML which has lot of content and a vertical scrollbar appears as soon as the HTML is loaded. Now from this HTML a full screen IFRAME is loaded. The problem is when the IFRAME is loaded, the parent scrollbar still persists, I want to disable the scrollbar when the Iframe is loaded.

I tried:

  • document.body.scroll = "no", it did not work with FF and chrome.
  • document.style.overflow = "hidden"; after this I was still able to scroll, and the whole iframe would scroll up revealing the parent HTML.

My requirement is, when the IFRAME is loaded, we should never be able to scroll the entire IFRAME if the parent HTML has a scrollbar.

Any ideas?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html