Location origin Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Location

Description

The origin property returns the protocol, hostname and port number of a URL.

This property is read-only.

Return Value

A String, representing the protocol, the domain name or IP address and port number of the URL.

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials