Window


How to use the Window class of the bit Butil?

Usage
To use the browser window features you need to inject the Bit.Butil.Window class and use it like this:
@inject Bit.Butil.Window window

@code {
    await window.AddEventListener(ButilEvents.KeyDown, args => { ... });
    await window.Alert("Alert from C#");
}
Methods

AddBeforeUnload, RemoveBeforeUnload:
The beforeunload event is fired when the current window, contained document, and associated resources are about to be unloaded. The main use case for this event is to trigger a browser-generated confirmation dialog that asks users to confirm if they really want to leave the page when they try to close or reload it, or navigate somewhere else. This is intended to help prevent loss of unsaved data (MDN).


AddEventListener, RemoveEventListener:
Sets up a function that will be called whenever the specified event is delivered to the window (MDN).


GetInnerHeight:
Gets the height of the content area of the browser window in px including, if rendered, the horizontal scrollbar (MDN).



GetInnerWidth:
Gets the width of the content area of the browser window in px including, if rendered, the vertical scrollbar (MDN).



IsSecureContext:
Returns a boolean indicating whether the current context is secure (true) or not (false) (MDN).


GetLocationBar:
Returns the locationbar object. For privacy and interoperability reasons, the value of the visible property is now false if this Window is a popup, and true otherwise (MDN).


SetName, GetName:
Gets/Sets the name of the window's browsing context (MDN).


GetOrigin:
Returns the global object's origin, serialized as a string (MDN).



GetOuterHeight:
Gets the height of the outside of the browser window in px (MDN).



GetOuterWidth:
Gets the width of the outside of the browser window in px (MDN).



GetScreenX:
Returns the horizontal distance in px from the left border of the user's browser viewport to the left side of the screen (MDN).


GetScreenY:
Returns the vertical distance in px from the top border of the user's browser viewport to the top side of the screen (MDN).


GetScrollX:
Returns the number of pixels that the document has already been scrolled horizontally (MDN).


GetScrollY:
Returns the number of pixels that the document has already been scrolled vertically (MDN).


Btoa:
Creates a base-64 encoded ASCII string from a string of binary data (MDN).



Atob:
Decodes a string of data which has been encoded using base-64 encoding (MDN).



Alert:
Displays an alert dialog (MDN).



Blur:
Sets focus away from the window (MDN).


Close:
Closes the current window (MDN).


Confirm:
Displays a dialog with a message that the user needs to respond to (MDN).



Find:
Searches for a given string in a window (MDN).


Focus:
Sets focus on the current window (MDN).


GetSelection:
Returns the selection text representing the selected item(s) (MDN).


MatchMedia:
Returns a MediaQueryList object representing the specified media query string (MDN).


Open:
Opens a new window (MDN).


Print:
Opens the Print Dialog to print the current document (MDN).


Prompt:
Returns the text entered by the user in a prompt dialog (MDN).


Scroll:
Scrolls the window to a particular place in the document (MDN).


ScrollBy:
Scrolls the document in the window by the given amount (MDN).


Stop:
This method stops window loading (MDN).