Home > Web Front-end > JS Tutorial > js method to realize automatic adaptive height of iframe_javascript skills

js method to realize automatic adaptive height of iframe_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:13:43
Original
1314 people have browsed it

The example in this article describes the method of realizing automatic adaptive height of iframe in js. Share it with everyone for your reference. The details are as follows:

When writing web pages, it is often necessary to automatically scale the iframe height. If a list is embedded in the ifram, then after adding data and refreshing the list, the iframe height will automatically extend. After deleting the 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. Just call this function after the tag.

<script type="text/javascript">
  autoAdjustWindow();
</script>
<script type="text/javascript">
//自动调整iframe的高度,自适应树的展开和收缩
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>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template