Jquery-based iframe self-adaptive highly-scripting compatible with various browsers

Source: Internet
Author: User
I found a lot of iframe self-adaptive height scripts on the Internet, which is not compatible with browsing. Therefore, I want to use jquery's strong compatibility to write an iframe self-adaptive height script. Jquery is very powerful and the code is very simple:

The Code is as follows:


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


One thing to note is that I also found it during debugging, which delayed a lot of time. The binding event must be bound before the iframe is loaded. Otherwise, the binding event will not be executed.


The following is an overview of jQuery and load events.

Bind a handler to each load event that matches the element.

If it is bound to a window object, it is triggered after all content is loaded, including the window, frame, object, and image. If it is bound to an element, it is triggered after the content of the element is loaded.

Note: The load handler is triggered only after the element is fully loaded. If it is bound later, it will never be triggered. Therefore, do not bind the load event in $ (document). ready (), because jQuery will bind the load event after all DOM loads are completed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.