Javascript examples for Browser Object Model:Location
The href property sets or gets the entire URL of the current page.
Set the href property with the following Values
Value | Type | Description |
---|---|---|
URL | String | Sets the URL of the link. |
Possible values:
A String, representing the entire URL of the page
The following code shows how to return the entire URL of the current page:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w .j av a2s . c om var x = location.href; document.getElementById("demo").innerHTML = x; } </script> </body> </html>