IFRAME PROBLEM

Iam using an IFRAME inside a table. Iam not using any height attribute for the table <TR><td>.... and I have not mentioned any height attribute for IFRAME also. Inside the IFRAME iam displaying a page. When the page gets displayed intside the IFRAME I get a scroll bar, but I want the IFRAME to get extended instead of having a scroll bar.

Need Solution....
ramsharma23Asked:
Who is Participating?
 
BatalfConnect With a Mentor Commented:
If you don't want to specify any width or height attribute on your iframe, you probably have to resize the <iframe> from the file in the iframe.


Example:

In your main page
<iframe src="page2.html" id="myIframe"></iframe>


and page2.html:

<html>
<head>
    <script>
    function resizeParent(){
        var obj= parent.document.getElementById('myIframe');
        obj.style.width = (document.body.offsetWidth/1 + document.body.scrollWidth/1) + 'px';
        obj.style.height = (document.body.offsetHeight + document.body.scrollHeight/1) + 'px';
       
    }
    </script>
</head>    
<body onload="resizeParent()">
<table width="500" height="500">
    <tr>
        <td><p>Hello</td>
    </tr>
</table>
</body>
</html>
0
 
sajuksCommented:
//try this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script>
function reSize(){
  var fB = window.frames.frm.document.body;
  fB.style.overflow = "hidden";
  window.frames.frm.resizeTo(fB.scrollWidth,fB.scrollHeight)
 
}
</script>
</HEAD>

<BODY>

<iframe src = "c:\1.html" onLoad="reSize()"  name ="frm" id ="frameid"></iframe>
</BODY>
</HTML>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.