A Blazor wrapper for the Window interface from the HTML Specification.
This interface standardizes methods for controlling the global object used in browser windows called Window
. This project implements a wrapper around the interface and its types for Blazor so that we can easily and safely work with all the methods, attributes, and events surfaced in the Window
interface.
These functionalities are vast, and we do not wish to support them all, as some of them are of little use or work against the principles of Blazor. Here, I have made a high-level list of the different functionalities that the Window
interface supplies and marked which this wrapper will cover.
- 🚫 Access to the top level
Document
of the window. - ✅ Navigation control for the window.
- ✅ Option to register WebComponents using the
CustomElementRegistry
. - 🚫 Attributes indicating whether toolbar, scrollbars, location bar, etc. are visible.
- ✅ Access to the parent
WindowProxy
that this window is hosted in/by in case it is in an iframe or is a pop-up window. - ✅ Option to open a new window given some URL and target.
- 🚫 Attributes giving information about the user agent through the
Navigator
. - ✅ Initialize alert, confirm, prompt, and print user prompts.
- ✅ Posting messages to the window and listening for messages sent to it.
- ✅ Event listeners for events that are triggered when the user interacts with the window, such as mouse clicks, scrolling, resizing, etc.
- ✅ Event listeners for events related to the actions available in the window, such as changes in internet connectivity, changes in navigation location, or when the page is shown or hidden.
This wrapper is still under development.
The sample project can be demoed at https://kristofferstrube.github.io/Blazor.Window/
On each page, you can find the corresponding code for the example in the top right corner.
On the API Coverage Status page, you can see how much of the WebIDL specs this wrapper has covered.
The library uses the following other packages to support its features:
- https://github.com/KristofferStrube/Blazor.WebIDL (To make error handling JSInterop)
- https://github.com/KristofferStrube/Blazor.DOM (
Window
extendsEventTarget
)
This repository was built with inspiration and help from the following series of articles: