FAQ Topic - How do I communicate between frames in a web browser?

F

FAQ server

-----------------------------------------------------------------------
FAQ Topic - How do I communicate between frames in a web
browser?
-----------------------------------------------------------------------

To reference another frame, you simply need to step through the
frame hierarchy: « parent » is the page the frame is defined
in, « parent.framename » is another frame in the same frameset.
To access a variable called Moomin in a frame called Snork you
would use « parent.Snork.Moomin ». To call the function Snufkin
in that frame you would use « parent.Snork.Snufkin() ».


===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.
 
E

Evertjan.

FAQ server wrote on 14 feb 2007 in comp.lang.javascript:
To reference another frame, you simply need to step through the
frame hierarchy: « parent » is the page the frame is defined
[..]

Shouldn't that be:

window.parent [just parent for short]

?

In general the FAQ should show complete references like:

document.location.href = '...'
 
V

VK

In general the FAQ should show complete references like:
document.location.href = '...'

window.location.href = "..."

document.location should not be used for assignment.
That is one of exceptions to simply memorize to speak the language
properly:

parent-parents but child - children (English language)

return false to prevent default action - but return true to prevent
default action for
1) onerror, 2) onmouseover (for status change), 3) omouseout (for
status change)

read property either from window.location or document.location - but
change property
only over window.location

As any historical exception each one has its own explanation which
modern speaker should not be bothered with. For the curious ones - and
skipping on English exceptions :) -

onerror and status bar change are among the first handlers with pre-
historic event model in mind which is gone long ago except these. In
that model the logic was pretty much reversed against the current one.
Currently:
- Proceed with default action?
- No (false)

Pre-historic one:
- Prevent default action?
- Yes (true)

With location object historically (DOM 0) it was implemented for both
window and document objects but it was read/write for window and read-
only for document. The original intent of it is a bit obscure.
Possibly it reflects early ideas of how to implement multi-document
display - which is later went by other way to become frames. Unlike
handlers exception this one is almost gone out of use so on many
modern UAs document.location is write-allowed as well. Still there are
UAs following the old grammar, one of them is Safari.
This way a modern speaker should always use window.location form and
never document.location to be properly understood by everyone.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top