Location port Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Location

Description

The port property sets or gets the port number for a URL.

Set the port property with the following Values

Value Type Description
port String Sets the port number of the URL

Return Value

A String, representing the port number of a URL.

The following code shows how to return the port number of the current URL:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo"></p>

<script>
    document.getElementById("demo").innerHTML = "The URL port number of the current page is: " + window.location.port;
</script>//from www.j  a  va 2  s  .  co m

</body>
</html>

Related Tutorials