Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > iframe

Reply
Thread Tools

iframe

 
 
Jeff Thies
Guest
Posts: n/a
 
      07-04-2003
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
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-04-2003
Jeff Thies <(E-Mail Removed)> 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 - http://www.velocityreviews.com/forums/(E-Mail Removed)
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
form have 2 iframe.problem to input text in other iframe elca Python 0 10-21-2009 10:00 AM
how to use an iframe as a link (make the whole iframe clickable) mi HTML 4 05-21-2008 10:13 PM
Targeting a parent iframe from a sub-iframe albanitus@yahoo.com HTML 0 11-15-2006 04:40 PM
IFRAME - Refresh Table on Parent Window - maintain IFRAME State Scott ASP General 6 04-14-2004 05:48 AM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments