Using iframe tag the content inside the tag is displayed with a default size if the height and width are not specified. thou the height and width are specified then also the content of the iframe tag is not displayed in the same size of the main content. It is difficult to set the size of the content in the iframe tag as same as the main content. So its need to be dynamically set the content size when the content of iframe is loaded on the web page. Because its not possible to set the height and width all the time while the same code execute with a different content.
There is a way to make it dynamically by using some attribute of JavaScript.
The attributes used here are,
- contentWindow : This property returns the Window object used by an iframe element, basically its defines the iframe window.
- scrollHeight : This property defines the entire height of an element in pixels, the element is iframe.
- scrollWidth : This property defines the entire width of an element in pixels, the element is iframe.