https://github.com/kristofferstrube/blazor.window
A Blazor wrapper for the Window interface from the HTML Specification.
https://github.com/kristofferstrube/blazor.window
Last synced: about 1 year ago
JSON representation
A Blazor wrapper for the Window interface from the HTML Specification.
- Host: GitHub
- URL: https://github.com/kristofferstrube/blazor.window
- Owner: KristofferStrube
- License: mit
- Created: 2024-03-26T23:34:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-18T22:35:26.000Z (over 1 year ago)
- Last Synced: 2025-05-07T03:04:12.483Z (about 1 year ago)
- Language: C#
- Size: 8.42 MB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[](/LICENSE)
[](https://github.com/KristofferStrube/Blazor.Window/issues)
[](https://github.com/KristofferStrube/Blazor.Window/network/members)
[](https://github.com/KristofferStrube/Blazor.Window/stargazers)
[](https://www.nuget.org/packages/KristofferStrube.Blazor.Window/)
# Blazor.Window
A Blazor wrapper for the [Window interface from the HTML Specification.](https://html.spec.whatwg.org/#the-window-object)
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.**
# Demo
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](https://kristofferstrube.github.io/Blazor.Window/Status) page, you can see how much of the WebIDL specs this wrapper has covered.
# Related repositories
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` extends `EventTarget`)
# Related articles
This repository was built with inspiration and help from the following series of articles:
- [Typed exceptions for JSInterop in Blazor](https://kristoffer-strube.dk/post/typed-exceptions-for-jsinterop-in-blazor/)