Module Brr.Loc

Browser location

TODO. Needs redesign/review.

Warning. We use the terminology and return data according to RFC 3986, not according to the broken HTML URLUtils interface.

Location URI

val uri : unit -> Jstr.t

uri () is the browser's location full URI.

val scheme : unit -> Jstr.t

scheme () is the scheme of uri ().

val host : unit -> Jstr.t

host () is the host of uri ().

val port : unit -> int option

port () is the port of uri ().

val path : unit -> Jstr.t

path () is the path of uri ().

val query : unit -> Jstr.t

query () is the query of uri ().

val fragment : unit -> Jstr.t

fragment () is fragment of uri () with the hash.

val set_fragment : Jstr.t -> unit

set_fragment frag sets the fragment of uri () to frag. This does not reload the page but triggers the Ev.hashchange event.

val update : ?⁠scheme:Jstr.t -> ?⁠host:Jstr.t -> ?⁠port:int option -> ?⁠path:Jstr.t -> ?⁠query:Jstr.t -> ?⁠fragment:Jstr.t -> unit -> unit

update ~scheme ~hostname ~port ~path ~query ~fragment () updates the corresponding parts of the location's URI.

Location changes

val hashchange : Jstr.t Note.event

hashchange occurs whenever the window's fragment changes with the new value of fragment ().

val set : ?⁠replace:bool -> Jstr.t -> unit

set replace uri sets to browser location to uri, if replace is true the current location is removed from the session history (defaults to false).

val reload : unit -> unit

reload () reloads the current location.