15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2 ✦ Window and Frame Objects (Chapter 16)<br />

msg = msg + “top name: “ + top.name + “”<br />

msg = msg + “parent name: “ + parent.name + “”<br />

msg = msg + “parent.document.title: “ + parent.document.title + “”<br />

msg = msg + “window name: “ + window.name + “”<br />

msg = msg + “self name: “ + self.name + “”<br />

msg = msg + “self.document.title: “ + self.document.title<br />

return msg<br />

}<br />

<br />

<br />

<br />

<br />

document.write(gatherWindowData())<br />

<br />

<br />

<br />

In the two frames (Figure 2-4), the references to the window and self object<br />

names return the name assigned to the frame by the frameset definition<br />

(JustAKid1 for the left frame, JustAKid2 for the right frame). In other words, from<br />

each frame’s point of view, the window object is its own frame. References to<br />

self.document.title refer only to the document loaded into that window frame.<br />

But references to the top and parent windows (which are one and the same in this<br />

example) show that those object properties are shared between both frames.<br />

Figure 2-4: Parent and top properties being shared by both frames<br />

147<br />

windowObject.parent

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!