Browser
The Browser module provides a collection of utilities for interacting with web browser APIs. It includes functions for managing fullscreen mode, detecting connection status, handling DOM events, controlling page scrolling, and accessing native features like sharing. It also offers methods to check user preferences and device capabilities.
Overview
exitFullscreen(): void
Exits fullscreen mode, if supported by the browser.
getLanguage(): string
Returns the user's preferred browser language.
getTheme(): "light" | "dark"
Gets the user's preferred theme (light or dark).
isCookieEnabled(): boolean
Checks if cookies are enabled in the browser.
isFullscreenEnabled(): boolean
Checks if the fullscreen API is available.
isOnline(): boolean
Checks if the browser is connected to the internet.
isShareable(): boolean
Checks if the native sharing API is available.
isTabActive(): boolean
Checks if the browser tab is active (visible).
isTouchDevice(): boolean
Checks if the device supports touch events.
on<K extends keyof HTMLElementEventMap>(target: HTMLElement | Document | Window, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void
Adds an event listener to a DOM element.
onOffline(listener: () => void): void
Adds a listener for the offline event.
onOnline(listener: () => void): void
Adds a listener for the online event.
onVisibilityChange(listener: () => void): void
Adds a listener for tab visibility changes.
requestFullscreen(element?: HTMLElement): void
Requests an element to enter fullscreen mode.
scrollToElement(target: string | HTMLElement, options?: ScrollIntoViewOptions): void
Smoothly scrolls to a target element on the page.
scrollToTop(options?: ScrollToOptions): void
Smoothly scrolls to the top of the page.
share(data: ShareData): Promise<void>
Uses the native API to share data such as title, text, URL, or files.