You can find the properties of the location object in Table 10.8.
Table 10.8. The Properties and Methods of the location Object
Property
NS2
NS3
NS4
NS6
IE3a
IE3b
IE4
IE5
IE5.5
IE6
hash
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the part of the href property that follows the hash mark (#), if any, as a string. See "Using the location Object's Properties" in this chapter for an example.
host
x
x
x
x
x
x
x
x
x
x
Read/write
The host property just joins the hostname and port properties, separated by a colon (like this, hostname : port ), as a string. See "Using the location Object's Properties" in this chapter.
hostname
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the host name part of the location or URL as a string. See "Using the location Object's Properties" in this chapter.
href
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the entire current URL as a string. See "Using the location Object's Properties" in this chapter.
pathname
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the filename or path specified by the object as a string. See "Using the location Object's Properties" in this chapter.
port
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the port number of an URL as a string. For example, in the URL http://www.starpowder.com:80/hello.html , the port is 80. See "Using the location Object's Properties" in this chapter.
protocol
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the protocol part of a URL, such as http:, ftp:, or file:, as a string. See "Using the location Object's Properties" in this chapter.
search
x
x
x
x
x
x
x
x
x
x
Read/write
Sets or gets the part of the href property following the question mark in that property, if there is one. This property is a string. For example, in the URL http://www.starpowder.com/inside.html? user =1 , this property will hold "user=1". If there is no question mark in the URL, this property will hold an empty string.