Posted By

jonkemp on 06/29/10


Tagged

javascript


Versions (?)

JavaScript Location Object


 / Published in: JavaScript
 

URL: http://www.devguru.com/technologies/ecmascript/quickref/location.html

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.

  1. // The hash property is a string beginning with a hash (#), that specifies an anchor name in an HTTP URL.
  2.  
  3. window.location.hash;
  4.  
  5. // The host property is a string comprising of the hostname and port strings.
  6.  
  7. window.location.host;
  8.  
  9. // The hostname property specifies the server name, subdomain and domain name (or IP address) of a URL.
  10.  
  11. window.location.hostname;
  12.  
  13. // The href property is a string specifying the entire URL, and of which all other Link properties are substrings.
  14.  
  15. window.location.href;
  16.  
  17. // The pathname property is a string portion of a URL specifying how a particular resource can be accessed.
  18.  
  19. window.location.pathname;
  20.  
  21. // The port property is a string specifying the communications port that the server uses.
  22.  
  23. window.location.port;
  24.  
  25. // The protocol property is the string at the beginning of a URL, up to and including the first colon (:).
  26.  
  27. window.location.protocol;
  28.  
  29. // The search property is a string beginning with a question mark that specifies any query information in an HTTP URL.
  30.  
  31. window.location.search;
  32.  
  33. // The reload method forces a reload of the window's current document.
  34.  
  35. window.location.reload([forceGet]);
  36.  
  37. // The replace method replaces the current History entry with the specified URL.
  38.  
  39. window.location.replace(URL);

Report this snippet  

You need to login to post a comment.