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
| Name | Type | Access | Description |
|---|---|---|---|
document | "Document" | Read | Gets the document. |
navigator | Navigator | Read | Gets the navigator. |
location | Location | Read | Gets the location. |
console | Console | Read | Gets the console. |
history | "History" | Read | Per-window History singleton. |
custom_elements | "CustomElementRegistry" | Read | Per-window CustomElementRegistry singleton. |
local_storage | Storage | Read | Per-Window in-memory key-value store (localStorage stub). |
session_storage | Storage | Read | Per-Window in-memory key-value store (sessionStorage stub). |
screen | "Screen" | Read | Browser screen geometry (stub — all dimensions are zero). |
visual_viewport | "VisualViewport" | Read | CSSOM View visual viewport (stub — all dimensions are zero in headless mode). |
inner_width | int | Read | Viewport inner width in CSS pixels (stub: 0). |
inner_height | int | Read | Viewport inner height in CSS pixels (stub: 0). |
outer_width | int | Read | Window outer width in CSS pixels (stub: 0). |
outer_height | int | Read | Window outer height in CSS pixels (stub: 0). |
scroll_x | float | Read | Horizontal scroll offset in CSS pixels (stub: 0.0). |
scroll_y | float | Read | Vertical scroll offset in CSS pixels (stub: 0.0). |
page_x_offset | float | Read | Alias for :attr:scroll_x (stub: 0.0). |
page_y_offset | float | Read | Alias for :attr:scroll_y (stub: 0.0). |
device_pixel_ratio | float | Read | Device pixel ratio (stub: 1.0). |
self | "Window" | Read | Self-reference alias for the Window object (WHATWG HTML §11.1.1). |
window | "Window" | Read | Self-reference alias; same object as :attr:self (WHATWG HTML §11.1.1). |
closed | bool | Read | Whether the window has been closed (WHATWG HTML §11.1.2). |
top | "Window" | Read | Top-most window in the browsing-context chain (WHATWG HTML §11.1.3). |
parent | "Window" | Read | Parent window in the browsing-context chain (WHATWG HTML §11.1.3). |
opener | None | Read | The window that opened this one (WHATWG HTML §11.1.3). |
screen_x | int | Read | Window left-edge position on the screen in CSS pixels (stub: 0). |
screen_y | int | Read | Window top-edge position on the screen in CSS pixels (stub: 0). |
screen_left | int | Read | Alias for :attr:screen_x (CSSOM View §9.2). |
screen_top | int | Read | Alias for :attr:screen_y (CSSOM View §9.2). |
name | str | Read/Write | Browsing-context name (WHATWG HTML §7.1.2). |
status | str | Read/Write | Legacy status bar text (WHATWG HTML §11.1.1). |
IntersectionObserver | type[IntersectionObserver] | Read | Constructor reference for :class:IntersectionObserver. |
ResizeObserver | type[ResizeObserver] | Read | Constructor reference for :class:ResizeObserver. |
MessagePort | type[MessagePort] | Read | Constructor reference for :class:MessagePort. |
MessageChannel | type[MessageChannel] | Read | Constructor reference for :class:MessageChannel. |
BroadcastChannel | type[BroadcastChannel] | Read | Constructor reference for :class:BroadcastChannel. |
crypto | "Crypto" | Read | Return the per-window :class:Crypto object stub. |
Crypto | type["Crypto"] | Read | Constructor reference for :class:Crypto. |
performance | "Performance" | Read | Return the per-window :class:Performance object. |
Performance | type["Performance"] | Read | Constructor reference for :class:Performance. |
frames | "Window" | Read | Return self — headless context has no frame children (WHATWG HTML §7.7.1). |
length | int | Read | Number of browsing-context child frames; always 0 in headless (WHATWG HTML §7.7.1). |
is_secure_context | bool | Read | Headless context is treated as secure (Secure Contexts §2). |
crossorigin_isolated | bool | Read | Always False — headless environment has no cross-origin isolation (WHATWG HTML §7.2.2). |
origin_agent_cluster | bool | Read | Always False — headless environment has no origin-keyed agent clusters (WHATWG HTML §7.2.2). |
location_bar | "BarProp" | Read | Location bar visibility stub; always not visible (WHATWG HTML §7.7.3). |
menu_bar | "BarProp" | Read | Menu bar visibility stub; always not visible (WHATWG HTML §7.7.3). |
personal_bar | "BarProp" | Read | Personal bar visibility stub; always not visible (WHATWG HTML §7.7.3). |
scroll_bars | "BarProp" | Read | Scrollbar visibility stub; always not visible (WHATWG HTML §7.7.3). |
status_bar | "BarProp" | Read | Status bar visibility stub; always not visible (WHATWG HTML §7.7.3). |
tool_bar | "BarProp" | Read | Toolbar visibility stub; always not visible (WHATWG HTML §7.7.3). |
navigation | `` | Read | Navigation API — headless stub, always None. |
locationbar | "BarProp" | Read | Alias for :attr:location_bar — IDL camelCase name (WHATWG HTML §7.3.4). |
menubar | "BarProp" | Read | Alias for :attr:menu_bar — IDL camelCase name (WHATWG HTML §7.3.4). |
personalbar | "BarProp" | Read | Alias for :attr:personal_bar — IDL camelCase name (WHATWG HTML §7.3.4). |
scrollbars | "BarProp" | Read | Alias for :attr:scroll_bars — IDL camelCase name (WHATWG HTML §7.3.4). |
statusbar | "BarProp" | Read | Alias for :attr:status_bar — IDL camelCase name (WHATWG HTML §7.3.4). |
toolbar | "BarProp" | Read | Alias for :attr:tool_bar — IDL camelCase name (WHATWG HTML §7.3.4). |
fetch | None | Read | Always None — Fetch API (network) is not available in headless mode. |
screen_width | int | Read | Total screen width in CSS pixels (headless stub: 0). |
screen_height | int | Read | Total screen height in CSS pixels (headless stub: 0). |
trusted_types | None | Read | Always None — Trusted Types API is not implemented in headless mode. |
external | "_External" | Read | Legacy window.external object stub (WHATWG HTML §11.5). |
speech_synthesis | None | Read | Always None — Web Speech API is not available in headless mode. |
caches | None | Read | Always None — Cache Storage API is not available in headless mode. |
index_db | None | Read | Always None — IndexedDB is not available in headless mode. |
scheduler | `` | Read | Always None — no Prioritized Task Scheduling API in headless mode. |
pub_key_credential | `` | Read | Always None — no WebAuthn API in headless mode. |
cookie_store | `` | Read | Always None — no Cookie Store API in headless mode. |
text_decoder | `` | Read | Always None — TextDecoder is not exposed via the Window IDL in headless mode. |
text_encoder | `` | Read | Always None — TextEncoder is not exposed via the Window IDL in headless mode. |
onunhandledrejection | Callable[[object], object] | None | Read | Gets the onunhandledrejection. |
Methods
| Signature | Description |
|---|---|
__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) → object | Return 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) → int | Queue 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) → int | Queue 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]") → int | Request 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) → int | Queue 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) → bool | No-op dialog stub per WHATWG HTML §8.5.1. |
prompt(message: str, default: str) → str | None | No-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) → bool | Always 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) → str | Decode a base64-encoded ASCII string (WHATWG Infra §1 / HTML §8.2.3). |
btoa(data: str) → str | Encode 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") → bool | Dispatch event through the ancestor tree. |