Writing to an IFRAME's innerHTML 
August 26th, 2008, 10:45 PM
| | | |
How do I set the innerHTML property of a contained IFRAME ?
Many thanks in advance,
Aaron | 
August 26th, 2008, 11:05 PM
| | | | re: Writing to an IFRAME's innerHTML
"Aaron Gray" <ang.usenet@gmail.comwrote in message
news:6hjb9rFmggg9U1@mid.individual.net... Quote: |
How do I set the innerHTML property of a contained IFRAME ?
| I got
window.frames["results"].document.body.innerHTML
This works on FF and Opera, but not on IE.
Aaron | 
August 26th, 2008, 11:15 PM
| | | | re: Writing to an IFRAME's innerHTML
"Aaron Gray" <ang.usenet@gmail.comwrites: Quote:
"Aaron Gray" <ang.usenet@gmail.comwrote in message
news:6hjb9rFmggg9U1@mid.individual.net... Quote: |
>How do I set the innerHTML property of a contained IFRAME ?
| >
I got
>
window.frames["results"].document.body.innerHTML
>
This works on FF and Opera, but not on IE.
>
| IIRC, window.frames["results"].document.contentWindow.document.body.innerHTML
should work on IE.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/ | 
August 26th, 2008, 11:15 PM
| | | | re: Writing to an IFRAME's innerHTML
"Joost Diepenmaat" <joost@zeekat.nlwrote in message
news:874p57zb2a.fsf@zeekat.nl... Quote:
"Aaron Gray" <ang.usenet@gmail.comwrites:
> Quote:
>"Aaron Gray" <ang.usenet@gmail.comwrote in message
>news:6hjb9rFmggg9U1@mid.individual.net... Quote: |
>>How do I set the innerHTML property of a contained IFRAME ?
| >>
>I got
>>
> window.frames["results"].document.body.innerHTML
>>
>This works on FF and Opera, but not on IE.
>>
| >
IIRC,
window.frames["results"].document.contentWindow.document.body.innerHTML
>
should work on IE.
| window.frames["result"].document.contentWindow.document
Is saying the above is null or not an object.
I have an IFRAME thus :-
<iframe id="result" name="result"></iframe>
Confused, they sure do make this stuff easy !
Aaron | 
August 26th, 2008, 11:25 PM
| | | | re: Writing to an IFRAME's innerHTML
"Aaron Gray" <ang.usenet@gmail.comwrites: Quote:
"Joost Diepenmaat" <joost@zeekat.nlwrote in message
news:874p57zb2a.fsf@zeekat.nl... Quote:
>"Aaron Gray" <ang.usenet@gmail.comwrites:
>> Quote:
>>"Aaron Gray" <ang.usenet@gmail.comwrote in message
>>news:6hjb9rFmggg9U1@mid.individual.net...
>>>How do I set the innerHTML property of a contained IFRAME ?
>>>
>>I got
>>>
>> window.frames["results"].document.body.innerHTML
>>>
>>This works on FF and Opera, but not on IE.
>>>
| >>
>IIRC,
>window.frames["results"].document.contentWindow.document.body.innerHTML
>>
>should work on IE.
| >
window.frames["result"].document.contentWindow.document
>
Is saying the above is null or not an object.
| http://msdn.microsoft.com/en-us/libr...92(VS.85).aspx
You may want to leave out the first "document". Quote: |
Confused, they sure do make this stuff easy !
| Of course they don't.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/ | 
August 26th, 2008, 11:35 PM
| | | | re: Writing to an IFRAME's innerHTML
"Joost Diepenmaat" <joost@zeekat.nlwrote in message
news:87wsi3xw09.fsf@zeekat.nl... Quote:
"Aaron Gray" <ang.usenet@gmail.comwrites:
> Quote:
>"Joost Diepenmaat" <joost@zeekat.nlwrote in message
>news:874p57zb2a.fsf@zeekat.nl... Quote:
>>"Aaron Gray" <ang.usenet@gmail.comwrites:
>>>
>>>"Aaron Gray" <ang.usenet@gmail.comwrote in message
>>>news:6hjb9rFmggg9U1@mid.individual.net...
>>>>How do I set the innerHTML property of a contained IFRAME ?
>>>>
>>>I got
>>>>
>>> window.frames["results"].document.body.innerHTML
>>>>
>>>This works on FF and Opera, but not on IE.
>>>>
>>>
>>IIRC,
>>window.frames["results"].document.contentWindow.document.body.innerHTML
>>>
>>should work on IE.
| >>
> window.frames["result"].document.contentWindow.document
>>
>Is saying the above is null or not an object.
| > http://msdn.microsoft.com/en-us/libr...92(VS.85).aspx | Wow, great documentation, looks really old stuff. Quote: |
You may want to leave out the first "document".
| Tried that :-
window.frames.result.contentWindow.document is null or not an object
Again Quote: Quote: |
>Confused, they sure do make this stuff easy !
| >
Of course they don't.
| Cant find any good documentation on it, tried W3C standard approach too.
Aaron | 
August 26th, 2008, 11:35 PM
| | | | re: Writing to an IFRAME's innerHTML
"Aaron Gray" <ang.usenet@gmail.comwrites: Quote: |
window.frames.result.contentWindow.document is null or not an object
| In the posts above you refer to
window.frames.results
with an S at the end.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/ | 
August 26th, 2008, 11:45 PM
| | | | re: Writing to an IFRAME's innerHTML
"Joost Diepenmaat" <joost@zeekat.nlwrote in message
news:87sksrxva2.fsf@zeekat.nl... Quote:
"Aaron Gray" <ang.usenet@gmail.comwrites:
> Quote: |
> window.frames.result.contentWindow.document is null or not an object
| >
In the posts above you refer to
>
window.frames.results
>
with an S at the end.
| Yes, its not that, sorry to confuse.
I am wondering whether it was banned as a secuity problem.
Aaron | 
August 27th, 2008, 12:55 AM
| | | | re: Writing to an IFRAME's innerHTML
On Aug 26, 5:38*pm, "Aaron Gray" <ang.use...@gmail.comwrote: Quote:
"Joost Diepenmaat" <jo...@zeekat.nlwrote in message
>
news:87sksrxva2.fsf@zeekat.nl...
> Quote: |
"Aaron Gray" <ang.use...@gmail.comwrites:
| > Quote: Quote: |
* * window.frames.result.contentWindow.document is null or not an object
| | > Quote: |
In the posts above you refer to
| >>>
Yes, its not that, sorry to confuse.
>
I am wondering whether it was banned as a secuity problem.
>
Aaron
| If the document in the iframe is on another site it will throw an
exception. Security issue.
If you catch the exception and show it in an alert box, it will say
something like:
"Error: Permission denied to get property Window.document"
I have recently accessed an iframe like so:
frames['name_of_the_frame'].document
here is another article on the topic: http://xkr.us/articles/dom/iframe-document/
As to the innerHTML, can I ask why you want this? I'm pretty certain
that if you are trying to manipulate the document in the iframe, you
don't want the innerHTML.
Here is where I recently piddled around with iframes: http://polisick.com/crossdomainformattempt.php | 
August 27th, 2008, 01:15 AM
| | | | re: Writing to an IFRAME's innerHTML
"Doug Gunnoe" <douggunnoe@gmail.comwrote in message
news:7fedabba-0565-401a-ab64-c10c0201f67b@59g2000hsb.googlegroups.com... -
Thats great, it works when on a button or on body onload, but not executed
as inline javascript.
That was my problem ! Quote:
>As to the innerHTML, can I ask why you want this? I'm pretty certain
>that if you are trying to manipulate the document in the iframe, you
>don't want the innerHTML.
| For test purposes when testing AJAX.
Thanks that helped alot !:)
Aaron | 
August 27th, 2008, 01:25 AM
| | | | re: Writing to an IFRAME's innerHTML
Its now a two liner :-
//
// getFrameDoc() - get the document for a frame window
//
// Note: this must be executed via body.onload or later
//
function getFrameDoc( frame)
{
var doc = (frame.contentWindow || frame.contentDocument);
return doc.document || doc
}
Aaron | 
August 27th, 2008, 01:55 AM
| | | | re: Writing to an IFRAME's innerHTML
"Aaron Gray" <ang.usenet@gmail.comwrote in message
news:6hjkv4Fm280pU1@mid.individual.net... Quote:
Its now a two liner :-
>
//
// getFrameDoc() - get the document for a frame window
//
// Note: this must be executed via body.onload or later
//
>
function getFrameDoc( frame)
{
var doc = (frame.contentWindow || frame.contentDocument);
return doc.document || doc
}
| I have also found this will only work for a frame got by id, not from
window.frames[] :-
var framedoc = getFrameDoc( document.getElementById('myframe'));
works, where :-
var framedoc = getFrameDoc( window.frames["myframe"])
throws an error.
Anyone throw some light on this ?
Thanks,
Aaron | 
August 27th, 2008, 02:25 AM
| | | | re: Writing to an IFRAME's innerHTML
Aaron Gray wrote: Quote: |
"Aaron Gray" <ang.usenet@gmail.comwrote [...]:
| Please do not write attribution novels, see <http://insideoe.com/>
(Windows Mail is Outlook Express's successor). Quote: Quote:
>function getFrameDoc( frame)
>{
> var doc = (frame.contentWindow || frame.contentDocument);
> return doc.document || doc
>}
| >
I have also found this will only work for a frame got by id, not from
window.frames[] :-
>
var framedoc = getFrameDoc( document.getElementById('myframe'));
>
works, where :-
>
var framedoc = getFrameDoc( window.frames["myframe"])
>
throws an error.
| You could be a bit more specific. Which error, on which line, in which
runtime environment?
PointedEars
P.S.: Firebug 1.2.0 (final) has been released! :)
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann | 
August 27th, 2008, 02:45 AM
| | | | re: Writing to an IFRAME's innerHTML
"Thomas 'PointedEars' Lahn" <PointedEars@web.dewrote in message
news:48B4AC04.8090301@PointedEars.de... Quote:
Aaron Gray wrote: Quote: |
>"Aaron Gray" <ang.usenet@gmail.comwrote [...]:
| >
Please do not write attribution novels, see <http://insideoe.com/>
(Windows Mail is Outlook Express's successor).
| I do not understand please elaborate. Quote: Quote: Quote:
>>function getFrameDoc( frame)
>>{
>> var doc = (frame.contentWindow || frame.contentDocument);
>> return doc.document || doc
>>}
| >>
>I have also found this will only work for a frame got by id, not from
>window.frames[] :-
>>
> var framedoc = getFrameDoc( document.getElementById('myframe'));
>>
>works, where :-
>>
> var framedoc = getFrameDoc( window.frames["myframe"])
>>
>throws an error.
| >
You could be a bit more specific. Which error, on which line, in which
runtime environment?
| IE7 the second line.
By Id :- http://www.aarongray.org/Test/JavaSc...ame-test2.html
By window.frames[] http://www.aarongray.org/Test/JavaSc...ame-test3.html
Its probably something very simple I am not familuar with yet.
Aaron | 
August 27th, 2008, 06:05 AM
| | | | re: Writing to an IFRAME's innerHTML
"Aaron Gray" <ang.usenet@gmail.comwrites: Quote:
var framedoc = getFrameDoc( document.getElementById('myframe'));
>
works, where :-
>
var framedoc = getFrameDoc( window.frames["myframe"])
>
throws an error.
| Without having read the rest of the thread, so I don't know what
getFrameDoc does, the important difference is likely to be that
document.getElementById('myframe')
returns the "iframe" element that is part of this document's DOM
tree, whereas
window.frames["myframe"]
evaluates to the window object of the page that is the content
of the frame.
I.e., one is a DOM element object in the scope of the current page,
the other is the window object of the nested page. They are quite
different objects. You probably want the latter.
/L
-
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.' | 
August 27th, 2008, 11:05 AM
| | | | re: Writing to an IFRAME's innerHTML
Aaron Gray a écrit : Quote:
>
Tried that :-
>
window.frames.result.contentWindow.document is null or not an object
| for sure : there is NO document in your iframe !
(no src)
does : window.frames.results
is same as : window.frames['results']
or : document.results
or : parent.results
Try with an html file (with empty body?) opened in your iframe
or/and (only because you've a name in your iframe) perhaps :
parent.results.contentWindow.document.body.innerHT ML
(not tested)
If in first step you open a file (*of same domain*) in your iframe,
probably you'll have no more problem of security.
--
sm | 
August 27th, 2008, 11:25 AM
| | | | re: Writing to an IFRAME's innerHTML
Lasse Reichstein Nielsen wrote: Quote:
"Aaron Gray" <ang.usenet@gmail.comwrites: Quote:
> var framedoc = getFrameDoc( document.getElementById('myframe'));
>>
>works, where :-
>>
> var framedoc = getFrameDoc( window.frames["myframe"])
>>
>throws an error.
| >
Without having read the rest of the thread, so I don't know what
getFrameDoc does, [...]
| the declaration was right above that, in the part that you snipped :)
Regards,
PointedEars
P.S.:
<***@hotpop.com>: host mx1.hotpop.com[38.113.3.81] said:
550 <***@hotpop.com>:
Recipient address rejected: Account closed due to inactivity.
No forwarding information is available. (in reply to RCPT TO command)
And your signature delimiter is borken; must be "--<SP><CR><LF>":
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk> | 
August 27th, 2008, 12:05 PM
| | | | re: Writing to an IFRAME's innerHTML
Aaron Gray a écrit : Quote:
>
var framedoc = getFrameDoc( window.frames["myframe"])
>
throws an error.
| Probably better with (if named iframe) :
var framedoc = getFrameDoc( parent.myframe );
or :
var framedoc = getFrameDoc( top.myframe );
Perhaps :
var framedoc = getFrameDoc( window.frames["myframe"])
Anyway it is much better to use ID
(with name that will no more work if the main page is itself in a frame)
Here is a code working in my Firefox 3 and IE 6:
<http://cjoint.com/data/iBmXw4PQVM_ecrit_frame.htm>
Extracts :
<script type="text/javascript">
function scrib(frameNameOrId, texto) {
var f = document.getElementById(frameNameOrId)?
document.getElementById(frameNameOrId) :
top[frameNameOrId];
f = (f.contentWindow || f.contentDocument || f);
f = f.document || f;
f.body.innerHTML = texto;
}
</script>
<iframe name="results" border=1></iframe>
<iframe id="result" border=1></iframe>
<p><a href="javascript :scrib('results','hello world')">test by name</a>
<p><a href="javascript :scrib('result','hello world')">test by id</a>
--
sm | 
August 27th, 2008, 03:55 PM
| | | | re: Writing to an IFRAME's innerHTML
Thomas 'PointedEars' Lahn wrote: Quote: |
And your signature delimiter is borken; must be "--<SP><CR><LF>":
| Would somebody explain me the word 'borken'? Google gives this answer in
english to the query define:borken
Borken is a Kreis (district) in the northwestern part of North
Rhine-Westphalia, Germany. Neighboring districts are Bentheim, Steinfurt,
Coesfeld ...
en.wikipedia.org/wiki/Borken (district)
I would otherwise think this means 'broken', but when it has been used at
least tens of times by a person, who admirably thoroughly corrects every
detail, then there is obviously a good reason to use this word 'borken'. | 
August 27th, 2008, 04:55 PM
| | | | re: Writing to an IFRAME's innerHTML
"optimistx" <optimistxPoista@poistahotmail.comwrites: Quote:
Would somebody explain me the word 'borken'? Google gives this answer in
english to the query define:borken
| http://www.urbandictionary.com/define.php?term=borken
Probably related to "borked".
/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.' | 
August 27th, 2008, 06:35 PM
| | | | re: Writing to an IFRAME's innerHTML
Lasse Reichstein Nielsen wrote on 27 aug 2008 in comp.lang.javascript : 1: Bork (IPA : børk)is the official language of Sweden, stolen by Norway as
of Friday 13. August, 1905. Closely related to the dialect of Japanese as
spoken by the aboriginal Ainu people, Bork is characterised by its
remarkably limited number of phonemes and ridiculously short alphabet.
<http://uncyclopedia.org/wiki/Bork>
2: Possibly derived from a word used repeatedly by the Swedish Chef of the
Muppets. In various skits, the Chef often repeats the phrase bork, bork,
bork. The word may refer to the often-failed experiments in the Chef's
cooking adventures.
<http://en.wiktionary.org/wiki/Bork>
3: a no no:
<http://www.youtube.com/watch?v=jc_UCc8EQcQ>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) | 
August 27th, 2008, 09:05 PM
| | | | re: Writing to an IFRAME's innerHTML
Evertjan. wrote: Quote:
Lasse Reichstein Nielsen wrote on 27 aug 2008 in comp.lang.javascript:
> Quote:
>"optimistx" <optimistxPoista@poistahotmail.comwrites:
>> Quote:
>>Would somebody explain me the word 'borken'? Google gives this
>>answer in english to the query define:borken
| >>
>http://www.urbandictionary.com/define.php?term=borken
>>
>Probably related to "borked".
| >
1: Bork (IPA : børk)is the official language of Sweden, stolen by
Norway as of Friday 13. August, 1905. Closely related to the dialect
of Japanese as spoken by the aboriginal Ainu people, Bork is
characterised by its remarkably limited number of phonemes and
ridiculously short alphabet. <http://uncyclopedia.org/wiki/Bork>
>
2: Possibly derived from a word used repeatedly by the Swedish Chef
of the Muppets. In various skits, the Chef often repeats the phrase
bork, bork, bork. The word may refer to the often-failed experiments
in the Chef's cooking adventures.
<http://en.wiktionary.org/wiki/Bork>
>
3: a no no:
<http://www.youtube.com/watch?v=jc_UCc8EQcQ>
| Oekee palajo inehmoelle kiitoksija näestä selevityksistä. On nii kivvoo ku
suap tiällä käöttöö muinaesta puhetta nii ku borken. | 
August 27th, 2008, 10:55 PM
| | | | re: Writing to an IFRAME's innerHTML
optimistx wrote on 27 aug 2008 in comp.lang.javascript : Quote:
Evertjan. wrote: Quote:
>Lasse Reichstein Nielsen wrote on 27 aug 2008 in
>comp.lang.javascript:
>> Quote:
>>"optimistx" <optimistxPoista@poistahotmail.comwrites:
>>>
>>>Would somebody explain me the word 'borken'? Google gives this
>>>answer in english to the query define:borken
>>>
>>http://www.urbandictionary.com/define.php?term=borken
>>>
>>Probably related to "borked".
| >>
>1: Bork (IPA : børk)is the official language of Sweden, stolen by
>Norway as of Friday 13. August, 1905. Closely related to the dialect
>of Japanese as spoken by the aboriginal Ainu people, Bork is
>characterised by its remarkably limited number of phonemes and
>ridiculously short alphabet. <http://uncyclopedia.org/wiki/Bork>
>>
>2: Possibly derived from a word used repeatedly by the Swedish Chef
>of the Muppets. In various skits, the Chef often repeats the phrase
>bork, bork, bork. The word may refer to the often-failed experiments
>in the Chef's cooking adventures.
><http://en.wiktionary.org/wiki/Bork>
>>
>3: a no no:
><http://www.youtube.com/watch?v=jc_UCc8EQcQ>
| >
Oekee palajo inehmoelle kiitoksija näestä selevityksistä. On nii
kivvoo ku suap tiällä käöttöö muinaesta puhetta nii ku borken.
| OK, moet in dat nu allemaal opeens zo maar optimistisch begrijpen,
even though Borken, Germany is just 40 km due South of where I live??
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|