JavaScripture
Contribute via GitHub Feedback

URL : Object

An object that represents a web address. Also provides methods to generate a url for a Blob so locally generated content can be passed to APIs that accept urls.

Constructors

new URL(url : String) : URL

Creates a new URL object for the provided url.

Example:

Run

Results:

 

new URL(relativeUrl : String, base : String) : URL

Creates a new URL for the relativeUrl using base as the base url.

Example:

Run

Results:

 

Instance Properties

hash : String

The hash portion of the URL.

Example:

Run

Results:

 

host : String

The host portion of the URL.

Example:

Run

Results:

 

hostname : String

The hostname portion of the URL.

Example:

Run

Results:

 

href : String

The effective value of the URL. Set this to replace the entire value.

Example:

Run

Results:

 

origin : String  

The origin of the URL.

Example:

Run

Results:

 

password : String

The password portion of the URL.

Example:

Run

Results:

 

pathname : String

The path portion of the URL.

Example:

Run

Results:

 

port : String

The port portion of the URL.

Example:

Run

Results:

 

protocol : String

The protocol portion of the URL.

Example:

Run

Results:

 

search : String

The search query portion of the URL. See also searchParams.

Example:

Run

Results:

 

searchParams : URLSearchParams

Helper object to manipulate the search portion of the URL.

Example:

Run

Results:

 

username : String

The username portion of the URL.

Example:

Run

Results:

 

URL Methods

createObjectURL(blob : Blob) : String

Creates a url for the specified blob that can be passed to methods that expect a url. When done with the returned url, call revokeObjectURL() to free the resources associated with the created url.

Example:

Run

Results:

 

revokeObjectURL(url : String) : undefined

Frees the resources associated with the url created by createObjectURL().

Example:

Run

Results: