Accessing an embeded iframe

T

trpost

I am using the following javascript to resize an iframe to 100% of the
contents, which works good:

<script type="text/javascript">
function autoIframe(frameId){
try{
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument :
frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight + 20;
}
catch(err){
window.status = err.message;
}
}
</script>

<iframe id="tree" name="tree" src="Table.php"
onload="if (window.parent && window.parent.autoIframe)
{window.parent.autoIframe('tree');}"
width="100%" frameborder="no" scrolling="no"></iframe>
</iframe>

Now I am including this code into a framework which wraps my iframe
within another iframe, which causes the script to fail:

<frame>
<iframe id="tree" name="tree" src="Table.php"
onload="if (window.parent && window.parent.autoIframe)
{window.parent.autoIframe('tree');}"
width="100%" frameborder="no" scrolling="no"></iframe>
</iframe>
</iframe>

Does anyone know how to adjust the javascript to access the embeded
iframe?
 
T

trpost

I am using the following javascript to resize an iframe to 100% of the
contents, which works good:

<script type="text/javascript">
function autoIframe(frameId){
try{
frame = document.getElementById(frameId);
innerDoc = (frame.contentDocument) ? frame.contentDocument :
frame.contentWindow.document;
objToResize = (frame.style) ? frame.style : frame;
objToResize.height = innerDoc.body.scrollHeight + 20;}

catch(err){
window.status = err.message;}
}

</script>

<iframe id="tree" name="tree" src="Table.php"
onload="if (window.parent && window.parent.autoIframe)
{window.parent.autoIframe('tree');}"
width="100%" frameborder="no" scrolling="no"></iframe>
</iframe>

Now I am including this code into a framework which wraps my iframe
within another iframe, which causes the script to fail:

<frame>
<iframe id="tree" name="tree" src="Table.php"
onload="if (window.parent && window.parent.autoIframe)
{window.parent.autoIframe('tree');}"
width="100%" frameborder="no" scrolling="no"></iframe>
</iframe>
</iframe>

Does anyone know how to adjust the javascript to access the embeded
iframe?

I solved this by running the javascript inline in the onload:

<iframe>
<iframe id="tree" name="tree" src="http://Table.php
"onload="document.getElementById('tree').height =
document.getElementById
('tree').contentWindow.document.body.scrollHeight + 20;" width="100%"
frameborder="no" scrolling="no"></iframe>
</iframe>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top