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

iframe innerHTML

P: n/a
(code is at end of post)
-------------------------------------------
I'm using an i-frame to grab a server-side text file and display its content
elsewhere in the html document. On change of the i-frame source, I want to
access its innerHTML.

The i-frame source changes just fine and even displays the source; the glitch
is in accessing the innerHTML for that new i-frame src file. It requires *TWO*
clicks of the onClick element to get the correct innerHTML (with just one
click, the source will change, and display the new file in the html document;
however, the innerHTML is still that of the old source file for the i-frame).
This does not appear to be a loading problem with the new src file into the
i-frame. (ie: setTimeout on a function to get the innerHTML after the src file
loads does not work).

So the question is: how can I get the i-frame source to change AND access the
new src file's innerHTML with one click??

Ideas, suggestions, changes appreciated.

Thankyou,

Jim
------------------- C O D E -------------------
// framer is the new src file name for the i-frame;
// eyeframe is the i-frame element id
// myframe is the i-frame element name
// centerbox inner is the div container for the new content

function contentChange(framer){
document.getElementById('eyeframe').src = framer;
document.getElementById('centerboxinner').innerHTM L
=window.frames['myframe'].document.body.innerHTML
}
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
>From: ji*******@aol.comNoSpam (JimMenees)
I'm using an i-frame to grab a server-side text file
and display its content elsewhere in the html document.
On change of the i-frame source, I want to access its
innerHTML.


Instead of trying to load it into an IFrame and then grab its
innerHTML, why not use an HTTPRequest to simply grab
the file, parse whats in the body, and then display it?

http://jibbering.com/2002/4/httprequest.html
--
Randy
Jul 20 '05 #2

P: n/a
hi************@aol.com (HikksNotAtHome) writes:
Instead of trying to load it into an IFrame and then grab its
innerHTML, why not use an HTTPRequest to simply grab
the file, parse whats in the body, and then display it?


Because there are more browsers supporting iframes and innerHTML
than HTTPRequest?

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

P: n/a
In article <ad**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
hi************@aol.com (HikksNotAtHome) writes:
Instead of trying to load it into an IFrame and then grab its
innerHTML, why not use an HTTPRequest to simply grab
the file, parse whats in the body, and then display it?


Because there are more browsers supporting iframes and innerHTML
than HTTPRequest?


When deciding how to do something, my first thought is always to try to do it
the most efficient way. And an HTTPRequest (where it works) is more efficient
than loading the file into an IFrame and reading it's innerHTML property. If
for no other reason, because you skip the browser having to render it first
before reading it.

But there are advantages and disadvantages to both approaches.
--
Randy
Jul 20 '05 #4

P: n/a
On 30 Dec 2003 23:33:03 GMT, hi************@aol.com (HikksNotAtHome)
wrote:
Because there are more browsers supporting iframes and innerHTML
than HTTPRequest?


When deciding how to do something, my first thought is always to try to do it
the most efficient way. And an HTTPRequest (where it works) is more efficient
than loading the file into an IFrame and reading it's innerHTML property. If
for no other reason, because you skip the browser having to render it first
before reading it.


also and in many cases more importantly for me, innerHTML in many
browsers doesn't give you the source document you tried to load, but a
normalised approximation of the parse tree it got from the document.
It also runs script etc.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.