Home > Web Front-end > JS Tutorial > jquery-based iframe adaptive height script compatible with various browsers_jquery

jquery-based iframe adaptive height script compatible with various browsers_jquery

WBOY
Release: 2016-05-16 18:21:21
Original
1240 people have browsed it

jquery is very powerful and the code is very simple:

Copy code The code is as follows:

$("# iPersonalInfo").load(function() {
$(this).height($(this).contents().height());
})

A little It should be noted that I only discovered this during debugging, which wasted a lot of time. That is, the binding event must be bound before the iframe is loaded, otherwise it will not be executed.


The following is an overview of jQuery, load event

Bind a handler function to the load event of each matching element.

If bound to the window object, it will be triggered after all content is loaded, including windows, frames, objects and images. If bound to an element, it fires when the element's content is loaded.

Note: Only if the load processing function is bound before this element is completely loaded, it will be triggered after it is loaded. If you bind it later, it will never trigger. So don't bind the load event in $(document).ready(), because jQuery will bind the load event after all DOM loading is completed.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template