Why can't I access child frame elements with the direct form?

R

Robert Oschler

I have a document that contains a child frame with name/id = "help_frame".
From Javascript in the top level document I can access the child frame's
elements using:

var elem = document.frames.help_frame.document.getElementById("chkSynonym");

but if I try:

var elem = document.frames.help_frame.document.chkSynonym;

the result is 'undefined'.

What is wrong with my syntax?

thx
 
L

Lasse Reichstein Nielsen

Robert Oschler said:
var elem = document.frames.help_frame.document.getElementById("chkSynonym");

I believe it is more correct to use "window.frames...". E.g., Mozilla
doesn't have "document.frames".
but if I try:
var elem = document.frames.help_frame.document.chkSynonym;
the result is 'undefined'.

What is wrong with my syntax?

The syntax is fine. Maybe the browser simply doesn't make named
elements available as properties of the document element (or maybe
just not all of them). There is no standard that requires it to do so.

If getElementById works, use it.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top