accessing IFrame innerHtml

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

accessing IFrame innerHtml

Post by mzfp2 »

Hi

I am having great trouble accessing the innerHTML (and changing it) for a IFrame on my page, using JavaScript.

Nothing seems to work in IE (I have managed to get it working in Firefox)

Can anyone help?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post your code.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

What you've done so far?
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

Post by mzfp2 »

Thaks for your replies,

I am using the following line of code

document.getElementById('rte1').contentWindow.document.body.innerHTML='Hello World';

However, instead of updating the Iframe's html content to read 'Hello World' a blank document replaces the current document, with the Hello World as the Text.

Iframe id is set to rte1.

Kind Regards
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

I'm pretty sure (If I understand you) what you want to do is not possible. You would need to change the location of the Iframe to change the content inside.

Maybe instead of using an IFrame use a div with overflow set to auto.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

PrObLeM wrote:I'm pretty sure (If I understand you) what you want to do is not possible.
as long as the target document originates from the same server as parent, it's possible.
Post Reply