iFrame Scrolling Without Body Scrolling
iFrame Scrolling Without Body Scrolling
(OP)
I just removed the obsolete frames from one of my very old legacy Web sites (created in the mid-'90s) and have it up and running with iFrames but I am unable to remove the body scrolling and show only the vertical iFrame scrolling. Is there a way to do it?
My CSS includes:
. . . and the HTML, simplified for this posting (meta tags removed), is something like:
In case it helps, the included Javascript contains:
My CSS includes:
CODE --> CSS
html { min-height: 100%; padding-bottom: 1px; } body { background-image: url('/images/systemimages/background.gif'); font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 13px; overflow: hidden; margin: 0; } iframe { position: relative; width: 100%; } iframe#main { overflow-y: auto; overflow: -moz-scrollbars-vertical; }
. . . and the HTML, simplified for this posting (meta tags removed), is something like:
CODE --> HTML
<!DOCTYPE HTML> <html> <head> <title>Site Name</title> <script language="JavaScript" src="/functions/iframes.js"></script> <script type="text/javascript"> window.onload = function () { setIframeHeight(document.getElementById('main')); };</script> </head> <body> <iframe src="/php/logo.php" name="logo" frameborder="0" scrolling="no" hspace="0" vspace="0" height="120"></iframe> <iframe src="/php/main.php" id="main" name="main" frameborder="0" scrolling="auto" hspace="0" vspace="0"> Please update your browser to view this and most other sites properly. </iframe> </body> </html>
In case it helps, the included Javascript contains:
CODE --> Javascript
function setIframeHeight(iframe) { if (iframe) { var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if (iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; } } };
RE: iFrame Scrolling Without Body Scrolling
Outside of that the <iframe> works as expected.
M. Brooks
http://mbrooks.info
RE: iFrame Scrolling Without Body Scrolling
CODE --> CSS
When I disable the scrolling in the iFrame, it works on the "home" page but then many others are either cut off or there is excessive background showing at the bottom. As it is now, there are two scroll bars and both seems to be needed in order to view the entire page but I want only the iFrame scroll bar.
RE: iFrame Scrolling Without Body Scrolling
CODE --> CSS
If I change overflow-x: hidden; to overflow: hidden; then there is no scrolling whatsoever either in the iFrame of in the browser window. The window scroll bar seems to be related to the iframe#main top padding as it scrolls just enough to view the page if it goes under the logo.
RE: iFrame Scrolling Without Body Scrolling
CODE --> CSS
html, body { background-image: url('/images/systemimages/background.gif'); font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 13px; overflow-x: hidden; overflow-y: auto; margin: 0; width: 100%; margin-bottom: 150px; } iframe { position: fixed; width: 100%; } iframe#logo { height: 120px; top: 0px; left: 0px; z-index: 150; } iframe#main { overflow-y: auto; overflow: -moz-scrollbars-vertical; padding-top: 120px; height: 100%; }
RE: iFrame Scrolling Without Body Scrolling
RE: iFrame Scrolling Without Body Scrolling
Some of the solutions I've tested use jQuery or a combination of jQuery and CSS but nothing works - and there are too many to post here but the most common is to add -webkit-overflow-scrolling: touch; to the styles. When I do this, though, the page is entirely blank and has only the background image.
Any ideas?
RE: iFrame Scrolling Without Body Scrolling
This is due to a known issue specific to the iPad. Adding the following CSS attributes should resolve the issue.
M. Brooks
http://mbrooks.info
RE: iFrame Scrolling Without Body Scrolling