Home  >  Article  >  Web Front-end  >  How to make iframe adaptive to front-end height in jquery

How to make iframe adaptive to front-end height in jquery

php中世界最好的语言
php中世界最好的语言Original
2018-04-26 15:27:181516browse

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

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 iframe


What are the implementation methods of AJAX secondary linkage

The 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn