change iFrame height from child function

Can you change an iFrame height dimensions from a function with-in the child frame?

I am doing a page on my work intranet which is only updateable via an online tool which lets you write HTML (only within the <BODY> tags), but strips out any JavaScript.

I can however use small amounts of JavaScript using onload, onclick, onmouseover... elements etc...

So I have imbedded an iFrame on the page which is just a dynamic table, but because I don't know how long the table will be, it causes scrollbar to appear.

I tried to change this from the onload element of the iFrame by doing this:

<IFRAME onload="this.style.pixelHeight=this.scrollHeight;" style="OVERFLOW: auto; WIDTH: 100%;height:;" src="mytablehtml.asp" frameBorder=0></IFRAME>

But for some reason this does not work??

So I would like to include a function inside the child frame that will test how tall it is and tell it's parent to resize if possible.

*** OR ***

Would like to have my current method corrected if wrong.

Reg's
m8rix
LVL 10
m8rixAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

devicCommented:
example:
======================
<IFRAME name=myiframe onload="this.style.height=document.frames.myiframe.document.body.scrollHeight;"
style="OVERFLOW: auto; WIDTH: 100%;height:;" src="child.html" frameBorder=0></IFRAME>
0
GwynforWebCommented:
you can detect the iframe height in a child and resize it, eg

<IFRAME id="f" src="child.htm ">
</IFRAME>

then in child.htm

<input type="button" onclick="if (parent.document.getElementById('f').height < 250) parent.document.getElementById('f').height=300">
0
m8rixAuthor Commented:
Thanks for your comments guys, but both of these suggestions failed. I get an access denied error
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

devicCommented:
you can not change iframe, if the iframe is not in the same domain
0
m8rixAuthor Commented:
Thanks for that, my two pages are on different domains :(

Is there any attributes you can get using:
document.frames.myiframe.document.body.SomeAttribute

I tried to read the innerHTML of the iFrame and got the same error.

Also, because I created the page that is included in the iFrame, can I change the security of the page somehow to allow the parent to read it?
0
devicCommented:
no way and forget all what beginns with "document." on foreign domain, because it's not your document.





you can use XMLHTTP:
=====================================
<html>
<body onload=init()>

<center><h2>hello m8rix!</h2></center>
<hr>
<script>
function LoadPage(theURL,theID)
{


   var objSrvHTTP;
       objSrvHTTP = new ActiveXObject("Msxml2.XMLHTTP.4.0");
       objSrvHTTP.open ("GET",theURL,false);
       objSrvHTTP.send ("");

        document.getElementById(theID).innerHTML=objSrvHTTP.responseText;

}

function init()
{
      LoadPage("http://www.yahoo.com","yahoo")
      LoadPage("http://www.ebay.com","ebay")
}
</script>
<table width=555 cellspacing=0 cellpadding=0 border=3>
      <td valign=top id=yahoo></td>
      <td valign=top id=ebay></td>
</table>

</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
m8rixAuthor Commented:
Thankyou... All comments made were very good. Thus leaving behind a great reference for the future.

reg's
m8rix
0
devicCommented:
thank you too!
0
GwynforWebCommented:
thx :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

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.