Home > Article > Web Front-end > How to make iframe adaptive to front-end height in jquery
This time I will bring you jqueryHow to make iframe adapt to the height of the front end, jquery makes the iframe adapt to the height of the front end. take a look. iframe code, pay attention to write ID
<iframe src="test.html" id="main" width ="700" height ="300" frameborder="0" scrolling="auto"></iframe>
jquery code one:
//注意:下面的代码是放在test.html调用 $(window.parent. document ).find("#main").load(function(){ var main = $(window.parent.document).find("#main"); var thisheight = $(document).height()+30; main.height(thisheight); });
jquery code two:
//注意:下面的代码是放在和iframe同一个页面调用 $("#main").load(function(){ var mainheight = $(this).contents().find("body").height()+30; $(this).height(mainheight); });
I believe you have mastered it after reading the case in this article For more exciting methods, please pay attention to other related articles on the php Chinese website!
Recommended reading:
JQuery cross-domain operation DOM method in iframeWhat are the implementation methods of AJAX secondary linkageThe above is the detailed content of How to make iframe adaptive to front-end height in jquery. For more information, please follow other related articles on the PHP Chinese website!