How to make iframe auto height or 100% ?
Hi readers,
Today we going to learn about website development . If you know iframe code then you also know about the iframe do not do auto height .
So, I'm here for this purpose how to do auto height or height=100% ?
Steps for making iframe auto height or height=100%
- Copy the following code :-
<script type="text/javascript"><!--//function sizeFrame(frameId) {
var F = document.getElementById(frameId);if(F.contentDocument) {F.height = F.contentDocument.documentElement.scrollHeight+30; //FF 3.0.11, Opera 9.63, and Chrome} else {
F.height = F.contentWindow.document.body.scrollHeight+30; //IE6, IE7 and Chrome
}
}
// window.onload=sizeFrame;
//--></script>
- Then search for </head>
- Paste it, above the head tag .
For example :-
<script type="text/javascript"><!--//function sizeFrame(frameId) {var F = document.getElementById(frameId);if(F.contentDocument) {F.height = F.contentDocument.documentElement.scrollHeight+30; //FF 3.0.11, Opera 9.63, and Chrome} else {
F.height = F.contentWindow.document.body.scrollHeight+30; //IE6, IE7 and Chrome}}// window.onload=sizeFrame; //--></script></head>
- Okay now final part , Add the following iframe code where you want ..
<iframe width="100%" id="myFrame" src="http://www.o2tricks.in" scrolling="no" frameborder="0" onload="sizeFrame('myFrame')">Powred By O2Tricks</iframe>
- Note:- Change the http://www.o2tricks.in to your link or page.
Thats it .
Thank you
No comments: