Win
@Js
class Win : Obj
Win models the DOM window object.
See pod doc for details.
Return the current window instance
Returns a reference to the parent of the current window or subframe, or null if this is the top-most window
Register a handler function that will be called automatically each time the position of the device changes
Scrolls the document in the window by the given amount
Log object to console
Return local storage instance for window
Push a new history item onto the history stack
Cancels a repeated action which was set up using setInterval
Ratio of physical pixels to the resolution in CSS pixels
Unregister location/error monitoring handlers previously installed using geoWatchPosition
Add new CSS style rules to this page
Reload the current page
Return the size of the screen in pixels
Returns a reference to the topmost window in the window hierarchy
Display a modal message box with the given text
Calls a function repeatedly, with a fixed time delay between each call to that function
Clears the delay set by setTimeout
Return session storage instance for window
Close this window
Hyperlink to the given Uri in this window
Return current scroll position of document in this window
Write given text to the system clipboard
Remove the given event handler from this window
Request the browser to perform an animation before the next repaint
Get the Uri for this window
Scrolls to a particular set of coordinates in the document
Display a confirmation dialog box with the given text
Go to previous page in session history
State at the top of the history stack
Call the specified function after a specified delay
Evaluate given JavaScript code
Read textual contents of the system clipboard
Return the size of the window viewport in pixels
Attach an event handler for the given event on this window
Return the Doc instance for this window
Go to next page in the session history
Modify the current history item
Get the the current position of this device
Open a new window
Void addStyleRules(Str rules)
Add new CSS style rules to this page.
Void alert(Obj obj)
Display a modal message box with the given text.
Void clearInterval(Int intervalId)
Cancels a repeated action which was set up using setInterval.
Void clearTimeout(Int timeoutId)
Clears the delay set by setTimeout.
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.
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.
Win close()
Close this window. Only applicable to windows created with open. Otherwise method has no effect. Returns this.
Bool confirm(Obj obj)
Display a confirmation dialog box with the given text. Returns true if ok was selected, false othterwise.
static Win cur()
Return the current window instance.
Float devicePixelRatio()
Ratio of physical pixels to the resolution in CSS pixels
Doc doc()
Return the Doc instance for this window.
static Obj eval(Str js)
Evaluate given JavaScript code.
Void geoClearWatch(Int id)
Unregister location/error monitoring handlers previously installed using geoWatchPosition. This feature is only available in secure contexts (HTTPS).
Void geoCurPosition(|DomCoord| onSuccess, |Err|? onErr, [Str:Obj]? opts)
Get the the current position of this device. This feature is only available in secure contexts (HTTPS).
Int geoWatchPosition(|DomCoord| onSuccess, |Err|? onErr, [Str:Obj]? opts)
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).
Void hisBack()
Go to previous page in session history.
Void hisForward()
Go to next page in the session history.
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") }
Void hisReplaceState(Str title, Uri uri, Str:Obj map)
Modify the current history item.
Str:Obj hisState()
State at the top of the history stack
Void hyperlink(Uri uri)
Hyperlink to the given Uri in this window.
Storage localStorage()
Return local storage instance for window.
Void log(Obj? obj)
Log object to console.
Func onEvent(Str type, Bool useCapture, |Event| handler)
Attach an event handler for the given event on this window. Returns callback function instance.
Win open(Uri uri, Str? winName, [Str:Str]? opts)
Open a new window. Returns the new window instance.
Win? parent()
Returns a reference to the parent of the current window or subframe, or null if this is the top-most window.
Void reload(Bool force)
Reload the current page. Use force to bypass browse cache.
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.
Void reqAnimationFrame(|This| f)
Request the browser to perform an animation before the next repaint.
Size screenSize()
Return the size of the screen in pixels.
This scrollBy(Int x, Int y)
Scrolls the document in the window by the given amount.
Point scrollPos()
Return current scroll position of document in this window.
This scrollTo(Int x, Int y)
Scrolls to a particular set of coordinates in the document.
Storage sessionStorage()
Return session storage instance for window.
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.
Int setTimeout(Duration delay, |This| f)
Call the specified function after a specified delay. Returns a timeoutId that can be used in clearTimeout.
Win top()
Returns a reference to the topmost window in the window hierarchy. If this window is the topmost window, returns self.
Uri uri()
Get the Uri for this window.
Size viewport()
Return the size of the window viewport in pixels.