window.location window.document.domain window.document.location.href window.document.location.pathname window.document.location.port window.document.location.protocol window.document.location.hash window.document.location.host window.document.location.hostname window.document.location.search -------------------------------------------------------------------------------- The Location object is part of a Window object and is accessed through the window.location property. It contains the complete URL of a given Window object, or, if none is specified, of the current Window object. All of its properties are strings representing different portions of the URL, which generally takes the following form: <protocol>//<host>[:<port>]/<pathname>[<hash>][<search>] You can create a Location object by simply assigning a URL to the location property of an object: window.location = "file:///c:/projects" window.location = "http://www.yahoo.com" The invocation of setting the window.location property immediately instructs the browser to perform the requested navigation. -------------------------------------------------------------------------------- Properites: hash The hash property is a string beginning with a hash (#), that specifies an anchor name in an HTTP URL. location.hash This instructs the browser to load the requested page and scroll to the anchor tag designated by the hash value. host The host property is a string comprising of the hostname and port strings. location.host hostname The hostname property specifies the server name, subdomain and domain name (or IP address) of a URL. location.hostname href The href property is a string specifying the entire URL, and of which all other Link properties are substrings. location.href pathname The pathname property is a string portion of a URL specifying how a particular resource can be accessed. document.write(location.pathname) This would produce : articles/todaysFeature.htm port The port property is a string specifying the communications port that the server uses. location.port protocol The protocol property is the string at the beginning of a URL, up to and including the first colon (:), which specifies the method of access to the URL, e.g. "http:", "mailto:", "ftp:", etc. location.protocol search The search property is a string beginning with a question mark that specifies any query information in an HTTP URL. This is the property we'll be working with in this article. location.search -------------------------------------------------------------------------------- Methods reload The reload method forces a reload of the window's current document, i.e. the one contained in the Location.href property. location.reload([bool-forceGet]) For example, onClick="window.location.reload(true)" would force a GET reload, ignoring the fact that the document may already be in the cache. replace The replace method replaces the current History entry with the specified URL. After calling the replace method, you cannot navigate back to the previous URL using the browser's Back button. location.replace(URL) -------------------------------------------------------------------------------- JavaScript Code: function get_domain() { return(window.document.location.hostname) } function get_base_domain() { //note: add arg that will determine depth to return //reverse the array so that we can work backwards, this will allow //multiple subdomains of unknown length without effect... var domain = new String() domain += window.document.location.hostname.split('.').reverse()[1] domain += '.' domain += window.document.location.hostname.split('.').reverse()[0] return(domain) } -------------------------------------------------------------------------------- Email: Username to Fully Qualified Username: