<iframe id="theIFrame" onLoad="resize()" style="width:100%; height:100%;" frameborder="0"></iframe>

I have this..

the src is file go.jsp


in go.jsp changes occur.. how can I resize go.jsp the iframe so that there wont be scrolling

dont give me solution use scorlling="no".. simply..data will be hidden below..I want to resize the page...

Sometime ago had seen an example given below on some other forum. See if this can lead you to any solution

<head>

<script language="JavaScript">
	function iFrameHeight() {
		if(document.getElementById && !(document.all)) {
			h = document.getElementById('iframename').contentDocument.body.scrollHeight;
			document.getElementById('iframename').style.height = h;
		}
		else if(document.all) {
			h = document.frames('iframename').document.body.scrollHeight;
			document.all.iframename.style.height = h;
		}
	}
</script>
</head>

<iframe onLoad="iFrameHeight();" src="test.html" scrolling="no" scroll="no" id="iframename" marginwidth="0" marginheight="0" frameborder="0" style="width:100%;"></iframe>
</body>
</html>

it doesnt work..

the problem is, it opens test.html..

but in test.html some changes occur.. and i need to resize the page again..

1.
      <head>
   2.
       
   3.
      <script language="JavaScript">
   4.
      function iFrameHeight() {
   5.
      if(document.getElementById && !(document.all)) {
   6.
      h = document.getElementById('iframename').contentDocument.body.scrollHeight;
   7.
      document.getElementById('iframename').style.height = h;
   8.
      }
   9.
      else if(document.all) {
  10.
      h = document.frames('iframename').document.body.scrollHeight;
  11.
      document.all.iframename.style.height = h;
  12.
      }
  13.
      }
  14.
      </script>
  15.
      </head>
  16.
       
  17.
      <iframe onLoad="iFrameHeight();" src="test.html" scrolling="no" scroll="no" id="iframename" marginwidth="0" marginheight="0" frameborder="0" style="width:100%;"></iframe>
  18.
      </body>
  19.
      </html>

assume thats Main.jsp


now this is test.html

function resize()
{
var h;
if(document.getElementById && !(document.all)) {

h = document.getElementById('theIFrame').contentDocument.body.scrollHeight;

document.getElementById('theIFrame').style.height = h;

}

else if(document.all) {

h = document.frames('theIFrame').document.body.scrollHeight;

document.all.theIFrame.style.height = h;

}

do i do that in test.html? it doesnt work...it gives member not found error..
how can i resize it in test.html..becoz its undergoing changes and s oned

you can always open go.jsp in the <iframe> by setting the attribute src="go.jsp" in the <iframe> tag.

Now on change in the go.jsp you can always call the js function iFrameHeight() by placing the following code snippet at the end of go.jsp file

<script language="javascript">
<!--
	parent.iFrameHeight();
//-->
</script>

and remove the attibute onLoad="iFrameHeight();" from the <iframe>

No need to have resize function in the page that is opened in the iframe. You can directly call the js function in main.jsp with parent.iFrameHeight();

thanks alot man,you solved the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.