By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,380 Members | 1,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,380 IT Pros & Developers. It's quick & easy.

iframe

P: n/a
I have an iframe (IE5):

<iframe name="frame1" id="frame1" src="some_source">test</iframe>

that test appears outside the iframe, the src contents are in the iframe
though

I'd like to read the iframe.

var frame1=document.getElementById('frame1').innerHTML ;

What I get is "test", not what the contents of the iframe actually is.

What have I done wrong?

Jeff
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jeff Thies <cy*******@sprintmail.com> writes:
I have an iframe (IE5):

<iframe name="frame1" id="frame1" src="some_source">test</iframe>

that test appears outside the iframe, the src contents are in the iframe
though

I'd like to read the iframe.

var frame1=document.getElementById('frame1').innerHTML ;

What I get is "test", not what the contents of the iframe actually is.

What have I done wrong?


You want to access the content page in the frame. That is a completely
different page, so its HTML is not part of the iframe element on this
page.

What you can do is either:

var frame1=document.getElementById('frame1');
var iframeDocument = frame1.contentWindow ? frame1.contentWindow.document
: frame1.contentDocument;
var root = iframeDocument.documentElement || iframeDocument.body;
var HTML = root.innerHTML;

or

var frame1Document = frames['frame1'].document;
var root = iframeDocument.documentElement || iframeDocument.body;
var HTML = root.innerHTML;

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.