/    Sign up×
Community /Pin to ProfileBookmark

can i Set IFRAME innerHTML ?

hi friends,
I am developing a javascript function to evaluate the contents (innerHTML) an iframe, and append some values to there contents. I want to write back this inner html to the iframe. i tried to do it like this

[CODE]document.documentElement.innerHTML = sometext;[/CODE]

but it returned the follwing error:
[COLOR=Red][I]
Could not set the innerHTML property. Invalid target element for this operation. [/I]
[/COLOR]

can you suggest an idea to do this please?

thanking,
shinu

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JSep 04.2005 — Try this

window["iframe_name"].document.body.innerHTML

where iframe_name is the name you have given to the iframe
Copy linkTweet thisAlerts:
@shinujohnauthorSep 04.2005 — thanks mr.j

but i want to replace the whole html string, including the header section.

any way now i am just doing

[B]Iframe.contentWindow.document.write(sometext);[/B]

i am not sure whether it is reliable.

shinu.
Copy linkTweet thisAlerts:
@Mr_JSep 04.2005 — What are you putting in the head section?

You said you wanted to append to the contents not the head section ?
×

Success!

Help @shinujohn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...