Javascript examples for Browser Object Model:Location
The origin property returns the protocol, hostname and port number of a URL.
This property is read-only.
A String, representing the protocol, the domain name or IP address and port number of the URL.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j a v a 2 s .c om*/ var x = location.origin; document.getElementById("demo").innerHTML = x; } </script> </body> </html>