Home >Web Front-end >JS Tutorial >Teach you how to use jquery to implement iframe adaptive height_jquery

Teach you how to use jquery to implement iframe adaptive height_jquery

WBOY
WBOYOriginal
2016-05-16 16:45:001401browse

iframe code, pay attention to write ID

Copy code The code is as follows:




jquery code one:

Copy code The code is as follows:

//Note: The following code is placed in test. html calls
$(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:

Copy code The code is as follows:

//Note: The following code is placed Call
$("#main").load(function(){
var mainheight = $(this).contents().find("body").height() 30;
$(this).height(mainheight);
});
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