Declan Naughton wrote:
Seeing as window.frames isn't a part of any w3c standard, surely there
must be another (standards-compliant) way to access the properties of a
document included using the iframe or object elements (preferably
object)... right?
Like many things, standards compliance is not an absolute on the Web. In
fact, there is no fully standards-compliant approach to the DOM as the W3C
DOM standards define only interfaces that can be implemented. However, the
implementation always is proprietary; so is also `document' or
`window.document' to implement _also_ the HTMLDocument interface of W3C DOM
Level 2 HTML. One could only argue that
document.getElementById("myIframeId").contentDocum ent
as Lasse suggested, is "more standards-compliant" than
window.frames[myIframeId].contentDocument
because the proprietary part of the former is "smaller". But I doubt this
holds water. However, knowing this, I also tend to call something
"standards compliant" if only the implementation is the proprietary part of
the reference.
Trying to achieve maximum standards compliance can have its drawbacks. For
example, usually you want to give your IFrame a name instead of an ID
because UAs want the `name' attribute value for the `target' attribute
value of a[href]s. Trying to be standards compliant here would mean
document.getElementsByName("myIframeName")[0].contentDocument
(not as this reference worm, of course) as compared to
window.frames[myIframeName].contentDocument
Certainly I would almost always prefer the latter here as first
alternative in a collection of dependent feature tests; it has
broader support, and is more efficient. Hopefully, the Web API
Specification will make that quasi-standard a specified standard
eventually.
Please quote the minimum of what you are replying to --
<URL:http://jibbering.com/faq/faq_notes/pots1.html>
<URL:http://www.safalra.com/special/googlegroupsreply/>
-- and don't use buggy Web interfaces to NetNews such as Developersdex's
AspNNTP. Google Groups' interface is slightly better than that (at least
it supports threads properly and with a few tweaks also automatic
quotation), but a newsreader program is best.
PointedEars
--
#define QUESTION ((bb) || !(bb))
// William Shakespeare (if he would have been a hacker ;-))