/ Published in: JavaScript
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// The hash property is a string beginning with a hash (#), that specifies an anchor name in an HTTP URL. window.location.hash; // The host property is a string comprising of the hostname and port strings. window.location.host; // The hostname property specifies the server name, subdomain and domain name (or IP address) of a URL. window.location.hostname; // The href property is a string specifying the entire URL, and of which all other Link properties are substrings. window.location.href; // The pathname property is a string portion of a URL specifying how a particular resource can be accessed. window.location.pathname; // The port property is a string specifying the communications port that the server uses. window.location.port; // The protocol property is the string at the beginning of a URL, up to and including the first colon (:). window.location.protocol; // The search property is a string beginning with a question mark that specifies any query information in an HTTP URL. window.location.search; // The reload method forces a reload of the window's current document. window.location.reload([forceGet]); // The replace method replaces the current History entry with the specified URL. window.location.replace(URL);
URL: http://www.devguru.com/technologies/ecmascript/quickref/location.html