Mega Code Archive

 
Categories / JavaScript Tutorial / Location
 

Location

The Location object represents the current Web address displayed in the browser. Properties and Methods of the Location Object Property/MethodDescription hashRepresents an anchor name in the URL that begins with the # character hostRepresents the hostname and port number of the URL hostnameRepresents the hostname part of the URL hrefRepresents the complete URL pathnameRepresents the pathname part of the URL portRepresents the port part of the URL protocolRepresents the protocol part of the URL reload()Reloads the current URL replace()Loads a new Web page in the current browser searchThe search part of the URL, including the ? <html>     <head>     <title> Creating a Location object</title>     </head>     <body>     <form name="form1">     Click the button to get the current location value.     <br><br><br>     <input type="button" name="getLoc" value="Get Location"        onClick='alert("The current location is: " + document.location)'>     <br>     </form>     </body>     </html>