0

Is there a way to make an Iframe expandable as needed? I have a web page with an Iframe to a second web page on a same server. The second web page has an expandable table. What I would like is when someone views the second page throught the Iframe and clicks on the table to expand, the Iframe will also expand to fit the size.

ranjeet
  • 540
  • 7
  • 16

2 Answers2

0
<script type="text/javascript">
//<![CDATA[
window.onload = function() {
var f = document.getElementById("mainframe");
function resize() {
var h = "";
var w = "";
if (f.contentDocument) {
h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
(f.contentDocument.documentElement,"").getProperty Value

("width");
} else if (f.contentWindow) {
h = f.contentWindow.document.body.scrollHeight + 5 + "px";
} else {
return;
}
f.setAttribute("height",h);
f.parentNode.setAttribute("height",h);
}
if (window.addEventListener) {
f.onload = resize;
} else if (f.attachEvent) {
f.attachEvent("onload", resize);
} else {
return;
}
resize();
}
//]]>
</script>

<iframe name="frm" id="mainframe" src="URL HERE" frameborder="0" allowtransparency="no" scrolling="no" target="_self" height="150"></iframe>

And here's the HTML code:

<a href="URL OF PAGE" target="content">Name Of Page</a>
Monika
  • 2,172
  • 15
  • 24
0

If the page is in same domain in that case following solution should work.

Make iframe automatically adjust height according to the contents without using scrollbar?

Community
  • 1
  • 1
PSK
  • 17,547
  • 5
  • 32
  • 43