473,796 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(f ramer){
document.getEle mentById('eyefr ame').src = framer;
document.getEle mentById('cente rboxinner').inn erHTML
=window.frames['myframe'].document.body. innerHTML
}
Jul 20 '05 #1
4 8916
>From: ji*******@aol.c omNoSpam (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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
In article <ad**********@h otpop.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.javas cript 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
9803
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 ---------------------------------------------------------------------------- -------------------------------------------- Here's how the site works: You should press a button in the rollover area in order to load a source file on an Iframe, this Iframe is actually hidden working as a Buffer. The body of this loaded Iframe is...
1
2352
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 frame, but cannot append to it - I know I could put a textarea form box in there, however that is my least prefered route in part because I have such little control over the display of the contents that appears inside a <textarea> are box.
7
4869
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+ doesn't seem to have the problem. I'm doing: this.iframe = document.createElement( 'iframe' ); this.iframe.id = this.id + 'wh'; this.iframe.style.display = 'none';
4
5142
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
11189
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 DIV: <IFRAME id=myframe style="display:none" src="..." onload="ShowNews(this)"></IFRAME>
14
18293
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
52831
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 name and ID and its visible in my DOM explorer just as the table I need is it. The table is added from ASP.NET via Response.Write(). I have tried both window.frames, document.getElementById and even document.getElementsByTagName, nothing has...
4
32176
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 and just read object's values? This is what I've tried so far without any success: document.getElementsByTagName("iframe").contentWindow; document.getElementsByTagName("iframe").innerHTML;
5
1628
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); document.writeln(x.name); //document.writeln(x.value);
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.