Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q18 Where does the target="" go when using location.href=""?

You are here: irt.org | FAQ | JavaScript | Link | Q18 [ previous next ]

By default when using location.href="fileName.html", the target is the current document.

When coding location.href="fileName.html" what we are actually coding is document.location.href="fileName.html" or self.location.href="fileName.html", the self specifies the current window, or window.location.href="fileName.html".

When we need to target another window we need to navigate the window object hierarchy, either by specifying the parent frame, or the top frame (which may in fact be the same thing).

top.location.href="fileName.html" targets the top document.

top.frameName.location.href="fileName.html" targets the frame frameName within the top document.

parent.location.href="fileName.html" targets the parent of the current document.

parent.frameName.location.href="fileName.html" targets the child frame frameName of the parent of the current document, i.e. a sibling frame.

©2018 Martin Webb