Javascript examples for Browser Object Model:Location
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 |
A String, representing the port number of a URL.
The following code shows how to return the port number of the current URL:
<!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>