This article describes the method of implementing the automatic adaptive height of iframe by JS. Share it for your reference. The details are as follows:
When writing web pages, you often need to use automatic scaling of the iframe height. If an iframe is embedded in the iframe, then after adding data, refreshing the list, the iframe height will automatically extend. After deleting data, the iframe height should be automatically shortened.
Copy the next piece of code to the html or jsp page where the iframe is located. After the </html> tag, just call this function.
<script type="text/javascript"> autoAdjustWindow();</script><script type="text/javascript">//Automatically adjust the height of the iframe, expand and shrink the adaptive tree function autoAdjustWindow(){ try{ window.frameElement.height=document.body.scrollHeight; window.frameElement.parentElement.height=document.body.scrollHeight; window.frameElement.width=document.body.scrollWidth; window.frameElement.parentElement.width=document.body.scrollWidth; }catch(e){ }}</script>I hope this article will be helpful to everyone's JavaScript programming.