type

Win

src @Js
class Win : Obj

Win models the DOM window object.

See pod doc for details.

methods

addStyleRules

Add new CSS style rules to this page.

alert

Display a modal message box with the given text.

clearInterval

Cancels a repeated action which was set up using setInterval.

clearTimeout

Clears the delay set by setTimeout.

clipboardReadText

Read textual contents of the system clipboard.

clipboardWriteText

Write given text to the system clipboard.

close

Close this window.

confirm

Display a confirmation dialog box with the given text.

cur

Return the current window instance.

doc

Return the Doc instance for this window.

eval

Evaluate given JavaScript code.

geoClearWatch

Unregister location/error monitoring handlers previously installed using geoWatchPosition.

geoCurPosition

Get the the current position of this device.

geoWatchPosition

Register a handler function that will be called automatically each time the position of the device changes.

hisBack

Go to previous page in session history.

hisForward

Go to next page in the session history.

hisPushState

Push a new history item onto the history stack.

hisReplaceState

Modify the current history item.

hyperlink

Hyperlink to the given Uri in this window.

localStorage

Return local storage instance for window.

log

Log object to console.

onEvent

Attach an event handler for the given event on this window.

open

Open a new window.

parent

Returns a reference to the parent of the current window or subframe, or null if this is the top-most window.

reload

Reload the current page.

removeEvent

Remove the given event handler from this window.

reqAnimationFrame

Request the browser to perform an animation before the next repaint.

screenSize

Return the size of the screen in pixels.

scrollBy

Scrolls the document in the window by the given amount.

scrollPos

Return current scroll position of document in this window.

scrollTo

Scrolls to a particular set of coordinates in the document.

sessionStorage

Return session storage instance for window.

setInterval

Calls a function repeatedly, with a fixed time delay between each call to that function.

setTimeout

Call the specified function after a specified delay.

top

Returns a reference to the topmost window in the window hierarchy.

uri

Get the Uri for this window.

viewport

Return the size of the window viewport in pixels.

Slot Details

addStyleRules

src Void addStyleRules(Str rules)

Add new CSS style rules to this page.

alert

src Void alert(Obj obj)

Display a modal message box with the given text.

clearInterval

src Void clearInterval(Int intervalId)

Cancels a repeated action which was set up using setInterval.

clearTimeout

src Void clearTimeout(Int timeoutId)

Clears the delay set by setTimeout.

clipboardReadText

src Void clipboardReadText(|Str| f)

Read textual contents of the system clipboard. Returns an empty string if the clipboard is empty, does not contain text, or does not include a textual representation of clipboard's contents.

The user has to interact with the page or a UI element in order for this feature to work.

clipboardWriteText

src Void clipboardWriteText(Str text)

Write given text to the system clipboard.

The user has to interact with the page or a UI element in order for this feature to work.

close

src Win close()

Close this window. Only applicable to windows created with open. Otherwise method has no effect. Returns this.

confirm

src Bool confirm(Obj obj)

Display a confirmation dialog box with the given text. Returns true if ok was selected, false othterwise.

cur

src static Win cur()

Return the current window instance.

doc

src Doc doc()

Return the Doc instance for this window.

eval

src static Obj eval(Str js)

Evaluate given JavaScript code.

geoClearWatch

src Void geoClearWatch(Int id)

Unregister location/error monitoring handlers previously installed using geoWatchPosition. This feature is only available in secure contexts (HTTPS).

geoCurPosition

src Void geoCurPosition(|DomCoord| onSuccess, |Err|? onErr := null, [Str:Obj]? opts := null)

Get the the current position of this device. This feature is only available in secure contexts (HTTPS).

geoWatchPosition

src Int geoWatchPosition(|DomCoord| onSuccess, |Err|? onErr := null, [Str:Obj]? opts := null)

Register a handler function that will be called automatically each time the position of the device changes. This method returns a watch ID value that then can be used to unregister the handler with the geoClearWatch method. This feature is only available in secure contexts (HTTPS).

hisBack

src Void hisBack()

Go to previous page in session history.

hisForward

src Void hisForward()

Go to next page in the session history.

hisPushState

src Void hisPushState(Str title, Uri uri, Str:Obj map)

Push a new history item onto the history stack. Use onpopstate to listen for changes:

// Event.stash contains state map passed into pushState
Win.cur.onEvent("popstate", false) |e| { echo("# state: $e.stash") }

hisReplaceState

src Void hisReplaceState(Str title, Uri uri, Str:Obj map)

Modify the current history item.

src Void hyperlink(Uri uri)

Hyperlink to the given Uri in this window.

localStorage

src Storage localStorage()

Return local storage instance for window.

log

src Void log(Obj? obj)

Log object to console.

onEvent

src Func onEvent(Str type, Bool useCapture, |Event| handler)

Attach an event handler for the given event on this window. Returns callback function instance.

open

src Win open(Uri uri := `about:blank`, Str? winName := null, [Str:Str]? opts := null)

Open a new window. Returns the new window instance.

parent

src Win? parent()

Returns a reference to the parent of the current window or subframe, or null if this is the top-most window.

reload

src Void reload(Bool force := false)

Reload the current page. Use force to bypass browse cache.

removeEvent

src Void removeEvent(Str type, Bool useCapture, Func handler)

Remove the given event handler from this window. If this handler was not registered, this method does nothing.

reqAnimationFrame

src Void reqAnimationFrame(|This| f)

Request the browser to perform an animation before the next repaint.

screenSize

src Size screenSize()

Return the size of the screen in pixels.

scrollBy

src This scrollBy(Int x, Int y)

Scrolls the document in the window by the given amount.

scrollPos

src Point scrollPos()

Return current scroll position of document in this window.

scrollTo

src This scrollTo(Int x, Int y)

Scrolls to a particular set of coordinates in the document.

sessionStorage

src Storage sessionStorage()

Return session storage instance for window.

setInterval

src Int setInterval(Duration delay, |This| f)

Calls a function repeatedly, with a fixed time delay between each call to that function. Returns an intervalId that can be used in clearInterval.

setTimeout

src Int setTimeout(Duration delay, |This| f)

Call the specified function after a specified delay. Returns a timeoutId that can be used in clearTimeout.

top

src Win top()

Returns a reference to the topmost window in the window hierarchy. If this window is the topmost window, returns self.

uri

src Uri uri()

Get the Uri for this window.

viewport

src Size viewport()

Return the size of the window viewport in pixels.