This property yields a reference to the current window in which a script is running. This means that the statement self.close() is effectively window.close().
This is another name for the window.window property in this context. However, self is useful because you can build reusable scripts with it that can be used with a variety of object types and instances. Don't forget that this can also refer to a Frame as well as a Window since they are both represented by the Window object.
The self property can be used without the window prefix because it belongs to the global object in a web browser window. Using the self keyword makes no difference to the functionality of a script but it makes it easier to understand. For the same reason, you may want to use the window property in the same way.
Prev | Home | Next |
SelectorArray.length | Up | Semantic event |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |