Link.port

JavaScript 1.0+, JScript 1.0+ Nav2+, IE 3+, Opera3+ Syntax

							link.port

Description

The port property of the Link object represents the port number in the URL. This is not always present in all URLs.

Example

Listing 7.374 shows how to obtain the port number if available. When the button is clicked, the port number for the link is displayed.

Listing 7.374 Accessing the port Number
<html>
<head>
<title> Using the port property of the Link object</title>
</head>
<body>

<script language="JavaScript">
<!--Hide

// displays the port number of the URL
function showport(){
     document.form1.text1.value = document.links[0].port;
}
// End Hide --->
</script>
							 Click the button to see the port number for the URL <form name="form1"> <a href=http://www.mcp.com:80/foo?something#foobar> ...

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.