Adjust width & height of iframe to fit with content in it: Problem solved
Ifrmae is an inline frame which is used to embed videos and documents from another link into the webpage or into the post. Very often we feel the necessity to embed various videos or many other document to make it live to make our post informative and more attractive. This can be done with a simple iframe tag of HTML and iframe generator But problem occurs when when we embed it on the page. The problem is to fix height and width of the content or videos that we embed into the pages. If we do not know HTML very well we can not do so. Again doing so is very hazardous task if we know HTML and it takes a lot of time. So making iframe tag manually for embedding something is not an easy task because it kills times and labors. So I have iframe code with java-script that solve the problem automatically. It will automatically adjust the width and height to make it fit for the post body. So friend try this code and set it to your page. Try this code it will solve the problem completely and it's simple:
<script language="JavaScript"> <!-- function autoResize(id){ var newheight; var newwidth; if(document.getElementById){ newheight=document.getElementById(id).contentWindow.document .body.scrollHeight; newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth; } document.getElementById(id).height= (newheight) + "px"; document.getElementById(id).width= (newwidth) + "px"; } //--> </script> <IFRAME SRC="usagelogs/default.aspx" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>
Suppose you want to embed a YouTube video into your post body, you have just to past the URL of the video into the SRC="--------------------" It will automatically adjust the width of the embedded content but what you will have to do is that you have to define the height of the embedded content. So dear, use it to your pages without any problem.
No comments