From: Dr J R Stockton on
In comp.lang.javascript message <hqjjli$4ug$1(a)news.eternal-
september.org>, Tue, 20 Apr 2010 00:04:16, Garrett Smith
<dhtmlkitchen(a)gmail.com> posted:
>Dr J R Stockton wrote:
>> In comp.lang.javascript message <4bca3d79$0$286$14726298(a)news.sunsite.dk
>>> , Sat, 17 Apr 2010 23:00:02, FAQ server <javascript(a)dotinternet.be>
>> posted:
>>
>>> FAQ Topic - How do I access a frame's content?
>>
>>> To reference another frame on the _same domain_:
>> Surely one can reference the frame independently of the domain (and
>>can
>> use that to set its style), and it is access to the content which
>> depends on the domain? If so, move that paragraph down past that to
>> which it does not apply.
>>
>
>The entry is regarding the frame/window object, not an IFRAME element.
>The `frames` collection answers how to do that.

For the intended class of FAQ reader, an iframe is a type of frame. If
the material does not apply to iframes, then "(not iframe)" is needed.

>>> is accessed as ` fwin.moomin `.
>> That is at best incomplete. In sitedata.htm, I use
>> Ifr.style.display="block"
>> FILE = Ifr.contentDocument.body
>> FILE = FILE.textContent || FILE.innerText // IE8 needs latter
>> and in linxchek.htm
>> DOC = Fram.contentDocument
>> St = DOC.body.textContent || DOC.body.innerText
>> A partial FAQ answer is a misleading answer.
>>
>
>You're accessing a the window through the iframe. That is another way
>to do it, and it works.
>
>Should the FAQ mention that approach, as well, including cross-browser
>issues? It might end up being too long for an FAQ entry.


If I had realised earlier what one can do with iframes in the manner
above, I would have done it earlier, which would have been useful.
OTOH, perhaps I could have done it with frames (though, as an element,
iframe seems easier to manipulate).


Perhaps a new section - "How do I work with iframes?", with the answer
written with the frame answer in mind.


The cross-browser issues that I recall are IE8 needing "||" above, and
onLoad apparently not working in IE8. If there are more, it could be
nice to know.

In respect of cross-browser, perhaps the FAQ should cite my
js-datex.htm.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7)
Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)
From: Garrett Smith on
Dr J R Stockton wrote:
> In comp.lang.javascript message <hqjjli$4ug$1(a)news.eternal-
> september.org>, Tue, 20 Apr 2010 00:04:16, Garrett Smith
> <dhtmlkitchen(a)gmail.com> posted:
>> Dr J R Stockton wrote:
>>> In comp.lang.javascript message <4bca3d79$0$286$14726298(a)news.sunsite.dk
>>>> , Sat, 17 Apr 2010 23:00:02, FAQ server <javascript(a)dotinternet.be>
>>> posted:
>>>
>>>> FAQ Topic - How do I access a frame's content?
>>>> To reference another frame on the _same domain_:
>>> Surely one can reference the frame independently of the domain (and
>>> can
>>> use that to set its style), and it is access to the content which
>>> depends on the domain? If so, move that paragraph down past that to
>>> which it does not apply.
>>>
>> The entry is regarding the frame/window object, not an IFRAME element.
>> The `frames` collection answers how to do that.
>
> For the intended class of FAQ reader, an iframe is a type of frame. If
> the material does not apply to iframes, then "(not iframe)" is needed.
>

No, an IFRAME is an element; a `frame` is a window object.

Can we stick to the subject and not try to classify people?

>>>> is accessed as ` fwin.moomin `.
>>> That is at best incomplete. In sitedata.htm, I use
>>> Ifr.style.display="block"
>>> FILE = Ifr.contentDocument.body
>>> FILE = FILE.textContent || FILE.innerText // IE8 needs latter
>>> and in linxchek.htm
>>> DOC = Fram.contentDocument
>>> St = DOC.body.textContent || DOC.body.innerText
>>> A partial FAQ answer is a misleading answer.
>>>
>> You're accessing a the window through the iframe. That is another way
>> to do it, and it works.
>>
>> Should the FAQ mention that approach, as well, including cross-browser
>> issues? It might end up being too long for an FAQ entry.
>
>
> If I had realised earlier what one can do with iframes in the manner
> above, I would have done it earlier, which would have been useful.
> OTOH, perhaps I could have done it with frames (though, as an element,
> iframe seems easier to manipulate).
>

I see it is confusing.

An IFRAME's `contentDocument` property, or `contentWindow` property,
where supported, will point to, respectively, either the window or the
document that is loaded in that IFRAME.

That IFRAME's contentWindow can also be accessed via the `frames`
collection. Thus:

document.getElementsByTagName("iframe")[0].contentWindow === frames[0]

- is true when the (non-frameset) document contains at least one IFRAME.

Does any part of that help? If so, which part?

>
> Perhaps a new section - "How do I work with iframes?", with the answer
> written with the frame answer in mind.
>
>
> The cross-browser issues that I recall are IE8 needing "||" above, and
> onLoad apparently not working in IE8. If there are more, it could be
> nice to know.
>

Use attachEvent for onload events in IFRAME elements IE.

> In respect of cross-browser, perhaps the FAQ should cite my
> js-datex.htm.
>
The js-datex.htm document might be appropriately suggested in a
discussion about a date-related faq entry.

The section on that entry regaring "postMessage" might also be moved to
a separate entry.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: nick on
On Apr 21, 7:55 pm, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> ...
> No, an IFRAME is an element; a `frame` is a window object.

I think that's the important distinction to make, and the thing people
often miss. I'm sure most of the regulars know this stuff, but let's
review.

<iframe id="my_iframe" name="my_iframe"></iframe>

So document.getElementById('my_iframe') is a DOM node in the parent
document, the "outer" part of the window. It can be styled as a block-
level element.

In contrast, document.frames('my_iframe') is a window object, much
like 'this' defaults to a window object. Here, 'my_iframe' refers to
the name attribute and not the id.

Another thing that might be worth mentioning is that targets in hrefs
and forms and the second parameter to window.open will cause pages to
load in the named (i)frame if it exists. This can be very useful in
combination with the iframe's onload event.

> ...
> Use attachEvent for onload events in IFRAME elements IE.

Good to know.

-- Nick
From: Garrett Smith on
Dr J R Stockton wrote:
> In comp.lang.javascript message <hqo38s$2m7$1(a)news.eternal-
> september.org>, Wed, 21 Apr 2010 16:55:05, Garrett Smith
> <dhtmlkitchen(a)gmail.com> posted:
>> Dr J R Stockton wrote:
>>> In comp.lang.javascript message <hqjjli$4ug$1(a)news.eternal-
>>> september.org>, Tue, 20 Apr 2010 00:04:16, Garrett Smith
>>> <dhtmlkitchen(a)gmail.com> posted:
>>>> Dr J R Stockton wrote:
>>>>> In comp.lang.javascript message <4bca3d79$0$286$14726298(a)news.sunsite.dk
>>>>>> , Sat, 17 Apr 2010 23:00:02, FAQ server <javascript(a)dotinternet.be>
>>>>> posted:
>>>>>
>>>>>> FAQ Topic - How do I access a frame's content?
>>>>>> To reference another frame on the _same domain_:
>>>>> Surely one can reference the frame independently of the domain (and
>>>>> can
>>>>> use that to set its style), and it is access to the content which
>>>>> depends on the domain? If so, move that paragraph down past that to
>>>>> which it does not apply.
>>>>>
>>>> The entry is regarding the frame/window object, not an IFRAME element.
>>>> The `frames` collection answers how to do that.
>>> For the intended class of FAQ reader, an iframe is a type of frame.
>>> If
>>> the material does not apply to iframes, then "(not iframe)" is needed.
>>>
>> No, an IFRAME is an element; a `frame` is a window object.
>
> Again, you are thinking in terms of the standard, and not considering
> what ordinary people will take words to mean. You are not supposed to
> be writing merely for Thomas Lahn, David Mark, and Richard Cornford.
>
>> Can we stick to the subject and not try to classify people?
>
> With one exception, for the FAQ there is no need to classify individuals
> (exception : if there were an entry in it about Thomas). But it is
> necessary to write for the right classes of people. The most important
> class is not that of the professional Web coders, who should know it all
> already; it is that of the normal people who wish to use JavaScript on
> connection with their other work, professional or amateur.
>
> The exception is that a FAQ maintainer needs to be in the class of good
> communicators.
>
>
>
>>>>>> is accessed as ` fwin.moomin `.
>>>>> That is at best incomplete. In sitedata.htm, I use
>>>>> Ifr.style.display="block"
>>>>> FILE = Ifr.contentDocument.body
>>>>> FILE = FILE.textContent || FILE.innerText // IE8 needs latter
>>>>> and in linxchek.htm
>>>>> DOC = Fram.contentDocument
>>>>> St = DOC.body.textContent || DOC.body.innerText
>>>>> A partial FAQ answer is a misleading answer.
>>>>>
>>>> You're accessing a the window through the iframe. That is another way
>>>> to do it, and it works.
>>>>
>>>> Should the FAQ mention that approach, as well, including cross-browser
>>>> issues? It might end up being too long for an FAQ entry.
>>> If I had realised earlier what one can do with iframes in the
>>> manner
>>> above, I would have done it earlier, which would have been useful.
>>> OTOH, perhaps I could have done it with frames (though, as an element,
>>> iframe seems easier to manipulate).
>>>
>> I see it is confusing.
>>
>> An IFRAME's `contentDocument` property, or `contentWindow` property,
>> where supported, will point to, respectively, either the window or the
>> document that is loaded in that IFRAME.
>
> Respectively?
>

Where supported:
contentDocument -> document
contentWindow -> window


>> That IFRAME's contentWindow can also be accessed via the `frames`
>> collection. Thus:
>>
>> document.getElementsByTagName("iframe")[0].contentWindow === frames[0]
>>
>> - is true when the (non-frameset) document contains at least one IFRAME.
>>
>> Does any part of that help? If so, which part?
>

[...]

>
> Some part of the FAQ should COVER obtaining a reference to an Object,
> including such as doc.gEBI, this.form, dot and ["string"], parent,
> child, name, etc., and then other parts of the FAQ can just say "Get a
> reference R to it (_Sec 35.26_), then ...". Example - section 9.7 (of
> Version 25) would say
>

As in:-

"What is a Reference?"
[explanation of Reference type]

- ?

> Using the non-standard but widely implemented innerHTML property, get a
> reference R to the target (_Sec 35.26_), and assign the new material to
> R.innerHTML.
>
For Reference type language feature, a focus on native objects with a
simple object, seems appropriate.


In that case, it would give rise to:

"What is an execution context?"

- under Functions.

That entry could also link to Dmitry article that explains about those
and most likely some good explanations in the archives here (hopefully
devoid of silliness).

> REMOVE : Where "anID" is the (unique on the HTML page)
> (is handled in 35.25) id attribute value of the element to modify.
>

You're switching the subject again, and now to the entry "How do I
modify the content of the current page?"

Regarding your comment for *that* entry, what do you mean by "handled in
35.25"?

> If the new content is only text and is not to replace existing HTML, it
> is better to modify the data property of a text node.
>
> R.firstChild.data = "Some new Text";
>
>
>
>
>>> Perhaps a new section - "How do I work with iframes?", with the
>>> answer
>>> written with the frame answer in mind.
>>> The cross-browser issues that I recall are IE8 needing "||" above,
>>> and
>>> onLoad apparently not working in IE8. If there are more, it could be
>>> nice to know.
>> Use attachEvent for onload events in IFRAME elements IE.
>
> Example?

myIframe.attachEvent("onload", myIframeLoadHandler);


Should there be an entry:

"How can I know when an IFRAME has loaded?"

?

[...]
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: nick on

> document.frames('my_iframe')

Argh, window.frames, not document.frames. You know what I meant.