Share this Page URL

Part VII: Appendixes > Basic DOM (Document Object Model) Objects - Pg. 250

JavaScript Quick Reference · Date.UTC converts a date object value (number of milliseconds) to a UTC (GMT) time. 250 Basic DOM (Document Object Model) Objects The DOM includes objects that represent the browser window, the current document, and its con- tents. The basic objects are summarized here, and explained in detail in Hour 10, "Working with the Document Object Model." More sophisticated DOM features are covered in Hours 17­19. Window The window object represents the current browser window. If multiple windows are open or frames are used, there may be more than one window object. These are given aliases to distinguish them: · self is the current window, as is window. This is the window containing the current JavaScript document. · top is the window currently on top (active) onscreen. · parent is a window that contains frames. Each frame is also a window object under parent. · The frames array contains the window object for each frame. These can be addressed as parent.frames[0] through the number of frames, or with their individual names, as in parent.docframe. The window object has three child objects: · The location object stores the location (URL) of the document displayed in the window. · The document object holds the Web page itself. · The history object contains a list of sites visited before or after the current site in the window. Location The location object contains information about the current URL being displayed by the window. It has a set of properties to hold the different components of the URL: · location.protocol is the protocol (or method ) of the URL. · location.hostname specifies the host name. · location.port specifies the communication port. · is a combination of the host name and port. · location.pathname is the directory to find the document on the host, and the name of the file. · location.hash is the name of an anchor within the document, if specified. · specifies the TARGET attribute of the link that was used to reach the cur- rent location. · location.query specifies a query string. · location.href is the entire URL. History The history object holds information about the URLs that have been visited before and after the current one in the window, and includes methods to go to previous or next locations: · history.back goes back to the previous location. · history.forward goes forward to the next location.