Location.port
JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax
location.port
Description
The port property of the Location object represents the port portion of the URL. This normally follows the hostname, but is not always available.
In the following fictitious Web address:
http://www.mcp.com:80/foo?something#foobar
the port value would be the 80 portion.
Example
Listing 7.385 shows how to get the port number.
Listing 7.385 Example of the port Property
<html> <head> <title> Using the port property of the Location object</title> </head> <body> <script language="JavaScript"> <!-- Hide // Function to display the port value function show(){ document.form1.text1.value=document.location.port; } // End Hide ---> </script> <form ... |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.