Neoliten
asked on
Iterate through all iframes in the document
I have a html document with code:
<body>
<iframe id="full_content_frame" src="tmpl_content1.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content2.htm" frameborder="0" width="100%">
</iframe>
......
</body>
and in tmpl_contentX.html I have:
<body onload="resizeIframe('full _content_f rame')">
.....
</body>
and main goal is to determine height of each frame and adjust iframe.height that all frames would be one by one vertically.
I am looking for any possibility to achieve that and one technique was successfull:
function resizeIframe(id)
{
parent.document.getElement ById(id).s tyle.heigh t = (this.document.body.scroll Height) + "px";
}
But it will correctly adjust only the first frame. How I can apply such method for all frames in parent document?
Or is there another flexible method to adjust numerous ifames?
<body>
<iframe id="full_content_frame" src="tmpl_content1.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content2.htm" frameborder="0" width="100%">
</iframe>
......
</body>
and in tmpl_contentX.html I have:
<body onload="resizeIframe('full
.....
</body>
and main goal is to determine height of each frame and adjust iframe.height that all frames would be one by one vertically.
I am looking for any possibility to achieve that and one technique was successfull:
function resizeIframe(id)
{
parent.document.getElement
}
But it will correctly adjust only the first frame. How I can apply such method for all frames in parent document?
Or is there another flexible method to adjust numerous ifames?
ASKER
Thanks, but how to do it automatically?
Becides, height of all frames would be the same.
Becides, height of all frames would be the same.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Check this:
<body>
<iframe id="full_content_frame" src="tmpl_content1.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content2.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content3.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content4.htm" frameborder="0" width="100%">
</iframe>
<script>
var frm = window.frames;
var pct = parseInt(1/frm.length*100) +"%";
alert(pct)
for(var i=0;i<frm.length;i++){
frm[i].frameElement.style. height=pct ;
}
</script>
</body>
<body>
<iframe id="full_content_frame" src="tmpl_content1.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content2.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content3.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content4.htm" frameborder="0" width="100%">
</iframe>
<script>
var frm = window.frames;
var pct = parseInt(1/frm.length*100)
alert(pct)
for(var i=0;i<frm.length;i++){
frm[i].frameElement.style.
}
</script>
</body>
<script type="text/javascript">
function doIt() {
var d = document.getElementsByTagN
for(var i = 0; i < d.length; i++) {
d[i].style.height = (this.document.body.scroll
}
}
</script>
<body>
<iframe id="full_content_frame" src="tmpl_content1.htm" frameborder="0" width="100%">
</iframe>
<iframe id="full_content_frame" src="tmpl_content2.htm" frameborder="0" width="100%">
</iframe>
<input type="button" onclick="doIt();" value="doIt();" />
</body>
-r-