Module history
Window, Location and History (HTML). Navigations requested by a module happen from a task of their own, never inside the call; same-document changes (pushState, fragments) fire popstate / hashchange as HTML says.
Exposed to: Window. Source: api/history.widl.
Odin: import "wren:history".
Types
handle Window : Object
The Window object (an EventTarget: popstate, hashchange, storage...).
enum ScrollRestoration : i32
What history.scrollRestoration says: whether the browser restores the scroll positions of an entry shown again.
| member | value | |
|---|---|---|
Auto | 0 | |
Manual | 1 |
Functions
Window_self
Window Window_self()window (the same object every time).
Host: Window_self :: proc(c: ^Call) -> u64
Document_self
Node Document_self()document, as a node (target of visibilitychange, readystatechange...).
Host: Document_self :: proc(c: ^Call) -> u64
Location_get
string Location_get(URLComponent component)location.href, location.protocol...
Host: Location_get :: proc(c: ^Call, component: Api_URLComponent) -> string
Location_set
void Location_set(URLComponent component, string value) raiseslocation.protocol = ..., location.hash = ... (href behaves like assign). Syntax for an invalid URL, Type when too long.
Raises: returns an Error (see web).
Host: Location_set :: proc(c: ^Call, component: Api_URLComponent, value: string) -> Api_Error
Location_assign
void Location_assign(string url) raiseslocation.assign(url)
Raises: returns an Error (see web).
Host: Location_assign :: proc(c: ^Call, url: string) -> Api_Error
Location_replace
void Location_replace(string url) raiseslocation.replace(url)
Raises: returns an Error (see web).
Host: Location_replace :: proc(c: ^Call, url: string) -> Api_Error
Location_reload
void Location_reload()location.reload()
Host: Location_reload :: proc(c: ^Call)
History_length
i32 History_length()history.length
Odin: history.length.
Host: History_length :: proc(c: ^Call) -> i32
History_state
string History_state() raiseshistory.state: Not_Found when null.
Odin: history.state.
Raises: returns an Error (see web).
Host: History_state :: proc(c: ^Call) -> (string, Api_Error)
History_pushState
void History_pushState(optional string state, optional string url) raiseshistory.pushState(state, "", url): Data_Clone past history.max_state_bytes, Syntax for an invalid URL, Security for a URL the document cannot be rewritten to.
Odin: history.pushState.
Raises: returns an Error (see web).
Host: History_pushState :: proc(c: ^Call, state: Maybe(string), url: Maybe(string)) -> Api_Error
History_replaceState
void History_replaceState(optional string state, optional string url) raiseshistory.replaceState(state, "", url)
Odin: history.replaceState.
Raises: returns an Error (see web).
Host: History_replaceState :: proc(c: ^Call, state: Maybe(string), url: Maybe(string)) -> Api_Error
History_go
void History_go(i32 delta = 0)history.go(delta): back() is go(-1), forward() go(1), go(0) reloads. Asynchronous.
Odin: history.go.
Host: History_go :: proc(c: ^Call, delta: i32)
History_scrollRestoration
ScrollRestoration History_scrollRestoration()history.scrollRestoration, of the current entry.
Odin: history.scrollRestoration.
Host: History_scrollRestoration :: proc(c: ^Call) -> Api_ScrollRestoration
History_set_scrollRestoration
void History_set_scrollRestoration(ScrollRestoration mode)history.scrollRestoration = mode, for the current entry (and the entries this document adds after it).
Odin: history.set_scrollRestoration.
Host: History_set_scrollRestoration :: proc(c: ^Call, mode: Api_ScrollRestoration)