Fit IFRAME content into page remove inner scrollbars
Hello I have an app where there is a top menu and a sidebar and an iframe all nested in a table. I know old school but that wasnt my decision.
I want the Iframe to fill the page based on the content length eliminate the iframe s开发者_高级运维crollbar and use the browser scrollbar to scroll.
Should I use javascript? can I just set everything to height 100% and then a specific overflow rule.
Right now I just have a min height on the iframe of 700px and a height of 100%
Depending if you want to the iframe to postback or not, you might be better off using the jquery .load() method, with this you could do the following
$(document).ready(function(){
$('#mydivid').load('anypage.html')
});
Doing this will eliminate the need to have an iframe altogether and might save you some hassle.
Alternatively if you wish to use the iframe you will need to calculate the height of the iframes content.
You can do this like so:
$(document).ready(function(){
var iframeheight = $('#myiframeid').find('body').height()
$('#myiframeid').height(iframeheight + 100)
});
You may need to run this after document ready as the iframe content may not complete loading when the $(document).ready() fires.
精彩评论