473,382 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

iframe innerHTML

(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
4 8880
>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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Javier | last post by:
Hello, I'm very new in this forum and as I have the following problem, the website is in http://new.vanara.com ----------------------------------------------------------------------------...
1
by: Reply Via Newsgroup | last post by:
Folks, I have a cell in a table that has an IFRAME - The IFRAME is empty (ie it has no source tag) but it does have a name (myFrame) and id (also called myFrame). I can write data to the...
7
by: Christopher J. Hahn | last post by:
I'm trying to use a script-generated form to submit to a script-generated iframe. The problem I'm running into is that the iframe is not assuming the name I assign it. IE6 on Win2000. FF1.0.2+...
4
by: L Anthony Johnson | last post by:
Has anyone had any success doing this. I have tried, but the InnerHTML property always comes back as an empty string. L Anthony Johnson
9
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible...
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
8
by: Henrik Stidsen | last post by:
I am trying to access a table in an iframe via javascript. It sounds easy - but it won´t work... The iframe is added to the document via someContainerElement.innerHTML = "<iframe...>", it has...
4
by: Yansky | last post by:
Is it possible to read the DOM of an iframe if the iframe's src is from another domain? I realise I can't manipulate the DOM from another domain for security reasons, but can I access the DOM...
5
by: Ketty | last post by:
Hi Experts, I am trying this bit of code which is not working right. <script language="JavaScript" type="text/JavaScript"> <!-- function showHide(divName) { var x = new getObj(divName);...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.