Home > Article > Web Front-end > In-depth analysis of the role of top in js_javascript skills
Every WINDOW object, whether it is a regular HTML page. Frameset page. Whether a child frame or a grandchild frame, both have a TOP attribute. This attribute returns a reference to the top-level WINDOE object loaded into the browser;
. If the WINDOW object is a regular HTML page, TOP is SELF
. . . . . . . Top-level frames and pages, . . . . . . . .
. . . . . . . Subframe, TOP points to the parent of the frame, that is to say, the following two expressions are equivalent;
SELF.TOP
SELF.PARENT
. If the WINDOW object is a subframe, TOP points to the frame's grandparent. In other words, the following two expressions are equivalent to
self.top
self.parent.parent
This may remind you of a good way to reduce keystrokes, especially if you think you can In order to only apply TOP itself (that is, use TOP itself instead of SELF.TOP or WINDOW.TOP), although this is feasible, special attention should be paid: you must ensure that TOP actually points to your top-level framework