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.