Skip to main content
interface URL

The URL interface represents an object providing static methods used for creating, parsing, and manipulating URLs.

Properties

hash: string

The hash property of the URL interface is a string that starts with a # and is followed by the fragment identifier of the URL. It returns an empty string if the URL does not contain a fragment identifier.

host: string

The host property of the URL interface is a string that includes the URL.hostname and the URL.port if one is specified in the URL includes by including a : followed by the port number.

hostname: string

The hostname property of the URL interface is a string that represents the fully qualified domain name of the URL.

href: string

The href property of the URL interface is a string that represents the complete URL.

readonly
origin: string

The origin property of the URL interface is a string that represents the origin of the URL, that is the URL.protocol, URL.host, and URL.port.

password: string

The password property of the URL interface is a string that represents the password specified in the URL.

pathname: string

The pathname property of the URL interface is a string that represents the path of the URL.

port: string

The port property of the URL interface is a string that represents the port of the URL if an explicit port has been specified in the URL.

protocol: string

The protocol property of the URL interface is a string that represents the protocol scheme of the URL and includes a trailing :.

The searchParams property of the URL interface is a URL.URLSearchParams object that represents the search parameters of the URL.

username: string

The username property of the URL interface is a string that represents the username of the URL.

Methods

toString(): string

The toString() method of the URL interface returns a string containing the complete URL.

toJSON(): string

The toJSON() method of the URL interface returns a JSON representation of the URL.

See

Back to top