adjusting the height of an iframe to fit the contents.

  • Thread starter Thread starter Cal Who
  • Start date Start date
C

Cal Who

I tried a couple of approches to adjusting the height of an iframe to fit
the contents.

I always get accessed denied.

A Javascript function that ran on onLoad also produced a denilal error.

Below is the last trial. The error points to 'document'

Has there been a change in the browses so that this is no longer possible?

Can you show me something that works.



<input type="button"
onclick="document.getElementById('myIframe').style.height
=myIframe.document.body.scrollHeight + 5" value="Ajust" />



Thanks
 
Cal said:
I tried a couple of approches to adjusting the height of an iframe to fit
the contents.

I always get accessed denied.

A Javascript function that ran on onLoad also produced a denilal error.

Below is the last trial. The error points to 'document'

Has there been a change in the browses so that this is no longer possible?

The same origin policy applies to client-side scripting. If you load
both the main document and the iframe document from the same origin then
your script in the main document can certainly read out properties of
the iframe document. However if the iframe contains a document from a
different origin (.e.g. the main document is from http://example.com/
and the iframe is from http://example.de/) then you will get the access
denied error with your attempt to read out the document or properties of
the document of the iframe.
 
Martin Honnen said:
The same origin policy applies to client-side scripting. If you load both
the main document and the iframe document from the same origin then your
script in the main document can certainly read out properties of the
iframe document. However if the iframe contains a document from a
different origin (.e.g. the main document is from http://example.com/ and
the iframe is from http://example.de/) then you will get the access denied
error with your attempt to read out the document or properties of the
document of the iframe.

I only used the source while testing anyway. So I now that I know I use a
file on my site which is what I need to do anyway.

Thanks
 
Back
Top