Is iframe height=100% supported in all browsers?
I am using doctype as:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
In my iframe code, if I say:
<iframe src="xyz.pdf" width="100%" height="100%" />
I mean will it actually take the height of the remaining page (as there is another frame on top with fixed height of 50px) Is this supported in all major browsers (IE/Firefox/Safari) ?
Also regarding scrollbars, even though I say scrolling="no"
, I can see disabled scrollbars in Firefox...How do I completely hide scrollbars and set the iframe height automatically?
This worked very nicely for me (only if iframe content comes from the same domain):
Here is a concise code. It does relies on a jquery method to find the current window height. On load of iFrame it sets the height of the iframe be the same as the current window. Then to handle resizing of the page, the body tag has an onresize event handler which sets the iframe's height whenever the document is resized.
here's a working sample: http://jsbin.com/soqeq/1/
Only this worked for me (but for "same-domain"):
you can use either:
or
1. Change your DOCTYPE to something less strict. Don't use XHTML; it's silly. Just use the HTML 5 doctype and you're good:
2. You might need to make sure (depends on the browser) that the iframe's parent has a height. And its parent. And its parent. Etc:
3 approaches for creating a fullscreen
iframe
:Approach 1 - Viewport-percentage lengths
In supported browsers, you can use viewport-percentage lengths such as
height: 100vh
.Where
100vh
represents the height of the viewport, and likewise100vw
represents the width.Example Here
Approach 2 - Fixed positioning
This approach is fairly straight-forward. Just set the positioning of the
fixed
element and add aheight
/width
of100%
.Example Here
Approach 3
For this last method, just set the
height
of thebody
/html
/iframe
elements to100%
.Example Here