The location Object

As mentioned earlier, one of the properties of every window is the location object. This object holds the current URL, including the hostname, path, CGI script arguments, and even the protocol. Table 19.1 shows the properties and methods of the location object.

Table 19.1. The Location Object Contains Information on the Currently Displayed URL
Name What It Does
Properties  
href Contains the entire URL, including all the subparts; for example, http://jim.odonnell.org:80/Que/location.html
protocol Contains the protocol field of the URL, including the first colon; for example, http:
host Contains the hostname and port number; for example, jim.odonnell.org:80
hostname Contains only the hostname; for example, jim.odonnell.org

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.