Methods of the DOM Location Object
(Page 1 of 4 )
In my last article I discussed the Dom Location Object Properties. Here, we will go over the Methods of those same objects, and if there is time, I will even cover the History Objects, which give you control over the user’s history list, allowing you to give them access to past URLs and advanced navigation.
Just to recap, the Dom Location Object Properties we covered in the last article included the hash, which allowed us to set or retrieve the part of the URL that follows the hash (#) symbol, used for anchors in HTML. We also discussed the host property, which returned the host name and the portnumber, except in cases where the portnumber is the default value of 80, in which case no portnumber was returned.
We also covered hostname, used to return just the hostname, and port, which returned or set just the portnumber, with the exception of course of the default value of 80. We also looked at href, which returned or set the entire URL, and pathname, which set or returned the path, such as /images/vacation/hippo.html.
In addition we covered protocol, which told us the protocol being used (ie; http: or ftp: ) and last, but certainly not least, we discussed search, which we can use to set or return the portion of a URL that follows the question mark (?).
Before we begin discussing the Methods of the Dom Location Objects, take a quick gander at our table:
Name | What It Does | Type |
assign() | Used when you wish to load a new document/page | Method |
reload() | Used when you want to reload the current page/document | Method |
replace() | Used when you wish to replace the current page/document with a new one | Method |
Next: Assign() Gives You Tasks >>
More JavaScript Articles
More By James Payne