getPort (XSPUrl - JavaScript)

Gets the port number of the URL.

Defined in

XSPUrl (JavaScript)

Syntax

getPort() : int
Return value Description
int The port number, or -1 if the port number is absent.

Example

This example prints the port number of the URL for the current context.
function p(stuff) {
	print("<<<" + stuff + ">>>");
}

var url : XSPUrl;
var port : int;

try {
	url = context.getUrl();
	port = url.getPort();
	if(port != -1)
		p("getPort = " + port);
	else
		p("getPort = No port number");

} catch(e) {
	p("Error = " + e);
}

Print output from the example might be as follows:

<<<getPort = 10038>>>