Window

Overview

Window is a class in Aspose.Html FOSS for Python. Inherits from: EventTarget.

Per-document window object with EventTarget behavior.

This class provides 38 methods for working with Window objects in Python programs. Available methods include: __init__, add_event_listener, alert, atob, blur, btoa, cancel_animation_frame, cancel_idle_callback, clear_interval, clear_timeout, close, confirm, and 26 additional methods. All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package. Properties: BroadcastChannel, Crypto, IntersectionObserver, MessageChannel, MessagePort, Performance, and 66 more.

Properties

NameTypeAccessDescription
document"Document"ReadGets the document.
navigatorNavigatorReadGets the navigator.
locationLocationReadGets the location.
consoleConsoleReadGets the console.
history"History"ReadPer-window History singleton.
custom_elements"CustomElementRegistry"ReadPer-window CustomElementRegistry singleton.
local_storageStorageReadPer-Window in-memory key-value store (localStorage stub).
session_storageStorageReadPer-Window in-memory key-value store (sessionStorage stub).
screen"Screen"ReadBrowser screen geometry (stub — all dimensions are zero).
visual_viewport"VisualViewport"ReadCSSOM View visual viewport (stub — all dimensions are zero in headless mode).
inner_widthintReadViewport inner width in CSS pixels (stub: 0).
inner_heightintReadViewport inner height in CSS pixels (stub: 0).
outer_widthintReadWindow outer width in CSS pixels (stub: 0).
outer_heightintReadWindow outer height in CSS pixels (stub: 0).
scroll_xfloatReadHorizontal scroll offset in CSS pixels (stub: 0.0).
scroll_yfloatReadVertical scroll offset in CSS pixels (stub: 0.0).
page_x_offsetfloatReadAlias for :attr:scroll_x (stub: 0.0).
page_y_offsetfloatReadAlias for :attr:scroll_y (stub: 0.0).
device_pixel_ratiofloatReadDevice pixel ratio (stub: 1.0).
self"Window"ReadSelf-reference alias for the Window object (WHATWG HTML §11.1.1).
window"Window"ReadSelf-reference alias; same object as :attr:self (WHATWG HTML §11.1.1).
closedboolReadWhether the window has been closed (WHATWG HTML §11.1.2).
top"Window"ReadTop-most window in the browsing-context chain (WHATWG HTML §11.1.3).
parent"Window"ReadParent window in the browsing-context chain (WHATWG HTML §11.1.3).
openerNoneReadThe window that opened this one (WHATWG HTML §11.1.3).
screen_xintReadWindow left-edge position on the screen in CSS pixels (stub: 0).
screen_yintReadWindow top-edge position on the screen in CSS pixels (stub: 0).
screen_leftintReadAlias for :attr:screen_x (CSSOM View §9.2).
screen_topintReadAlias for :attr:screen_y (CSSOM View §9.2).
namestrRead/WriteBrowsing-context name (WHATWG HTML §7.1.2).
statusstrRead/WriteLegacy status bar text (WHATWG HTML §11.1.1).
IntersectionObservertype[IntersectionObserver]ReadConstructor reference for :class:IntersectionObserver.
ResizeObservertype[ResizeObserver]ReadConstructor reference for :class:ResizeObserver.
MessagePorttype[MessagePort]ReadConstructor reference for :class:MessagePort.
MessageChanneltype[MessageChannel]ReadConstructor reference for :class:MessageChannel.
BroadcastChanneltype[BroadcastChannel]ReadConstructor reference for :class:BroadcastChannel.
crypto"Crypto"ReadReturn the per-window :class:Crypto object stub.
Cryptotype["Crypto"]ReadConstructor reference for :class:Crypto.
performance"Performance"ReadReturn the per-window :class:Performance object.
Performancetype["Performance"]ReadConstructor reference for :class:Performance.
frames"Window"ReadReturn self — headless context has no frame children (WHATWG HTML §7.7.1).
lengthintReadNumber of browsing-context child frames; always 0 in headless (WHATWG HTML §7.7.1).
is_secure_contextboolReadHeadless context is treated as secure (Secure Contexts §2).
crossorigin_isolatedboolReadAlways False — headless environment has no cross-origin isolation (WHATWG HTML §7.2.2).
origin_agent_clusterboolReadAlways False — headless environment has no origin-keyed agent clusters (WHATWG HTML §7.2.2).
location_bar"BarProp"ReadLocation bar visibility stub; always not visible (WHATWG HTML §7.7.3).
menu_bar"BarProp"ReadMenu bar visibility stub; always not visible (WHATWG HTML §7.7.3).
personal_bar"BarProp"ReadPersonal bar visibility stub; always not visible (WHATWG HTML §7.7.3).
scroll_bars"BarProp"ReadScrollbar visibility stub; always not visible (WHATWG HTML §7.7.3).
status_bar"BarProp"ReadStatus bar visibility stub; always not visible (WHATWG HTML §7.7.3).
tool_bar"BarProp"ReadToolbar visibility stub; always not visible (WHATWG HTML §7.7.3).
navigation``ReadNavigation API — headless stub, always None.
locationbar"BarProp"ReadAlias for :attr:location_bar — IDL camelCase name (WHATWG HTML §7.3.4).
menubar"BarProp"ReadAlias for :attr:menu_bar — IDL camelCase name (WHATWG HTML §7.3.4).
personalbar"BarProp"ReadAlias for :attr:personal_bar — IDL camelCase name (WHATWG HTML §7.3.4).
scrollbars"BarProp"ReadAlias for :attr:scroll_bars — IDL camelCase name (WHATWG HTML §7.3.4).
statusbar"BarProp"ReadAlias for :attr:status_bar — IDL camelCase name (WHATWG HTML §7.3.4).
toolbar"BarProp"ReadAlias for :attr:tool_bar — IDL camelCase name (WHATWG HTML §7.3.4).
fetchNoneReadAlways None — Fetch API (network) is not available in headless mode.
screen_widthintReadTotal screen width in CSS pixels (headless stub: 0).
screen_heightintReadTotal screen height in CSS pixels (headless stub: 0).
trusted_typesNoneReadAlways None — Trusted Types API is not implemented in headless mode.
external"_External"ReadLegacy window.external object stub (WHATWG HTML §11.5).
speech_synthesisNoneReadAlways None — Web Speech API is not available in headless mode.
cachesNoneReadAlways None — Cache Storage API is not available in headless mode.
index_dbNoneReadAlways None — IndexedDB is not available in headless mode.
scheduler``ReadAlways None — no Prioritized Task Scheduling API in headless mode.
pub_key_credential``ReadAlways None — no WebAuthn API in headless mode.
cookie_store``ReadAlways None — no Cookie Store API in headless mode.
text_decoder``ReadAlways None — TextDecoder is not exposed via the Window IDL in headless mode.
text_encoder``ReadAlways None — TextEncoder is not exposed via the Window IDL in headless mode.
onunhandledrejectionCallable[[object], object] | NoneReadGets the onunhandledrejection.

Methods

SignatureDescription
__init__(document: "Document")Calls init(document) on this Window instance.
queue_microtask(callback: "Callable[[], None]")Schedule callback as a microtask via the WindowEventLoop seam.
structured_clone(value: object, transfer: list | None)objectReturn a structured-clone-compatible deep copy of value.
print()Request a print dialog (no-op in headless mode).
stop()Stop loading the current document (no-op in headless mode).
scroll(x: float, y: float)Scroll the viewport to an absolute position — no-op in headless mode.
scroll_to(x: float, y: float)Scroll the viewport to an absolute position — no-op in headless mode.
scroll_by(x: float, y: float)Scroll the viewport by a relative delta — no-op in headless mode.
set_timeout(callback: "Callable[..., object]", delay: int)intQueue a one-shot timer callback and return its handle.
clear_timeout(id: int | None)Cancel a pending one-shot timer (idempotent for unknown handles).
set_interval(callback: "Callable[..., object]", delay: int)intQueue a repeating timer callback and return its handle.
clear_interval(id: int | None)Cancel a pending interval timer (idempotent for unknown handles).
request_animation_frame(callback: "Callable[[float], object]")intRequest an animation frame callback (no-op stub; returns 0).
cancel_animation_frame(id: int | None)Cancel an animation frame request (no-op stub).
request_idle_callback(callback: "Callable[..., object]", options: object | None)intQueue an idle callback request and return a deterministic integer id.
cancel_idle_callback(id: int | None)Cancel a pending idle callback request (idempotent no-op for unknown ids).
open(url: str, target: str, features: str)No-op browsing-context command stub per WHATWG HTML §8.8.2.
close()No-op browsing-context command stub per WHATWG HTML §8.8.1.
focus()No-op browsing-context command stub.
blur()No-op browsing-context command stub.
alert(message: str)No-op dialog stub per WHATWG HTML §8.5.1.
confirm(message: str)boolNo-op dialog stub per WHATWG HTML §8.5.1.
prompt(message: str, default: str)str | NoneNo-op dialog stub per WHATWG HTML §8.5.1.
get_computed_style(element: "Element", pseudo_elt: str | None)"ComputedStyleDeclaration"Return the computed style for element.
match_media(query: str)"MediaQueryList"Return a :class:MediaQueryList for query.
get_selection()"Selection"Return the :class:~aspose_html.dom.Selection for this window’s document.
post_message(message: object, target_origin: str, transfer: object)No-op stub — headless delivery semantics not supported (WHATWG HTML §7.7.5).
find(aString: str, aCaseSensitive: bool, aBackwards: bool, aWrapAround: bool, aWholeWord: bool, aSearchInFrames: bool, aShowDialog: bool)boolAlways returns False — headless find-in-page is not supported (WHATWG HTML §9.2.6).
move_to(x: int, y: int)No-op stub — headless has no OS window to reposition (CSSOM View §11).
move_by(dx: int, dy: int)No-op stub — headless has no OS window to move (CSSOM View §11).
resize_to(width: int, height: int)No-op stub — headless has no OS window to resize (CSSOM View §11).
resize_by(dwidth: int, dheight: int)No-op stub — headless has no OS window to resize (CSSOM View §11).
atob(data: str)strDecode a base64-encoded ASCII string (WHATWG Infra §1 / HTML §8.2.3).
btoa(data: str)strEncode a string to base64 (WHATWG Infra §1 / HTML §8.2.3).
report_error(e: object)No-op in headless mode.
add_event_listener(type: str, listener: Callable, capture: bool, once: bool)Register listener for events of type.
remove_event_listener(type: str, listener: Callable, capture: bool)Deregister a previously-registered listener.
dispatch_event(event: "Event")boolDispatch event through the ancestor tree.

See Also