Skip to content

Location

Types

t

The location (WebApiURL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively. See Location on MDN TODO: mark as private once mutating fields of private records is allowed

type t = {
mutable href: string,
origin: string,
mutable protocol: string,
mutable host: string,
mutable hostname: string,
mutable port: string,
mutable pathname: string,
mutable search: string,
mutable hash: string,
ancestorOrigins: WebAPI.DOM.domStringList,
}

Record fields

href
string

Returns the Location object's URL.

Can be set, to navigate to the given URL. Read more on MDN

origin
string

Returns the Location object's WebApiURL's origin. Read more on MDN

protocol
string

Returns the Location object's WebApiURL's scheme.

Can be set, to navigate to the same WebApiURL with a changed scheme. Read more on MDN

host
string

Returns the Location object's WebApiURL's host and port (if different from the default port for the scheme).

Can be set, to navigate to the same WebApiURL with a changed host and port. Read more on MDN

hostname
string

Returns the Location object's WebApiURL's host.

Can be set, to navigate to the same WebApiURL with a changed host. Read more on MDN

port
string

Returns the Location object's WebApiURL's port.

Can be set, to navigate to the same WebApiURL with a changed port. Read more on MDN

pathname
string

Returns the Location object's WebApiURL's path.

Can be set, to navigate to the same WebApiURL with a changed path. Read more on MDN

string

Returns the Location object's WebApiURL's query (includes leading "?" if non-empty).

Can be set, to navigate to the same WebApiURL with a changed query (ignores leading "?"). Read more on MDN

hash
string

Returns the Location object's WebApiURL's fragment (includes leading "#" if non-empty).

Can be set, to navigate to the same WebApiURL with a changed fragment (ignores leading "#"). Read more on MDN

ancestorOrigins

Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context. Read more on MDN

Values

assign

Navigates to the given URL. Read more on MDN

let assign: (t, string) => unit

Parameters

tstring

Return type

unit

fromDocument

The location object from document. See Location on MDN *

let fromDocument: t

fromWindow

The location object from window. See Location on MDN *

let fromWindow: t

reload

Reloads the current page. Read more on MDN

let reload: t => unit

Parameters

t

Return type

unit

replace

Removes the current page from the session history and navigates to the given URL. Read more on MDN

let replace: (t, string) => unit

Parameters

tstring

Return type

unit