Window
Window
概述
Window 是 Aspose.Html FOSS 中用于 Python 的类。继承自:EventTarget。
每个文档的窗口对象,具有 EventTarget 行为。
此类提供 38 个用于在 Python 程序中操作 Window 对象的方法。可用的方法包括:__init__、add_event_listener、alert、atob、blur、btoa、cancel_animation_frame、cancel_idle_callback、clear_interval、clear_timeout、close、confirm,以及另外 26 个方法。安装 Aspose.Html FOSS for Python 包后,所有公共成员对任何 Python 应用程序均可访问。属性:BroadcastChannel、Crypto、IntersectionObserver、MessageChannel、MessagePort、Performance,以及另外 66 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
document | "Document" | 读取 | 获取文档。 |
navigator | Navigator | 读取 | 获取 navigator。 |
location | Location | 读取 | 获取位置。 |
console | Console | 读取 | 获取控制台。 |
history | "History" | 读取 | 每窗口的 History 单例。 |
custom_elements | "CustomElementRegistry" | 读取 | 每窗口的 CustomElementRegistry 单例。 |
local_storage | Storage | 读取 | 每窗口的内存键值存储(localStorage 存根)。 |
session_storage | Storage | 读取 | 每窗口的内存键值存储(sessionStorage 存根)。 |
screen | "Screen" | 读取 | 浏览器屏幕几何(存根 — 所有维度均为零)。 |
visual_viewport | "VisualViewport" | 读取 | CSSOM View 视觉视口(存根 — 在无头模式下所有维度均为零)。 |
inner_width | int | 读取 | 视口内部宽度,以 CSS 像素为单位(存根:0)。 |
inner_height | int | 读取 | 视口内部高度,以 CSS 像素为单位(存根:0)。 |
outer_width | int | 读取 | 窗口外部宽度,单位为 CSS 像素(占位: 0)。 |
outer_height | int | 读取 | 窗口外部高度,单位为 CSS 像素(占位: 0)。 |
scroll_x | float | 读取 | 水平滚动偏移量(单位为 CSS 像素,存根:0.0)。 |
scroll_y | float | 读取 | 垂直滚动偏移量(单位为 CSS 像素,存根:0.0)。 |
page_x_offset | float | 读取 | :attr:scroll_x 的别名(存根:0.0)。 |
page_y_offset | float | 读取 | 别名为 :attr:scroll_y (存根: 0.0)。 |
device_pixel_ratio | float | 读取 | 设备像素比(存根:1.0)。 |
self | "Window" | 读取 | Window 对象的自引用别名(WHATWG HTML 第 11.1.1 节)。 |
window | "Window" | 读取 | 自引用别名;与 :attr:self 为同一对象(WHATWG HTML §11.1.1)。 |
closed | bool | 读取 | 窗口是否已关闭(WHATWG HTML §11.1.2)。 |
top | "Window" | 读取 | 浏览上下文链中最高层的窗口(WHATWG HTML §11.1.3)。 |
parent | "Window" | 读取 | 浏览上下文链中的父窗口 (WHATWG HTML §11.1.3)。 |
opener | None | 读取 | 打开此窗口的窗口 (WHATWG HTML §11.1.3)。 |
screen_x | int | 读取 | 窗口在屏幕上的左边缘位置,以 CSS 像素为单位 (stub: 0)。 |
screen_y | int | 读取 | 窗口在屏幕上的顶部位置,以 CSS 像素为单位(stub: 0)。 |
screen_left | int | 读取 | :attr:screen_x 的别名(CSSOM View §9.2)。 |
screen_top | int | 读取 | 别名为 :attr:screen_y (CSSOM View §9.2). |
name | str | 读写 | 浏览上下文名称 (WHATWG HTML §7.1.2). |
status | str | 读写 | 传统状态栏文本 (WHATWG HTML §11.1.1). |
IntersectionObserver | type[IntersectionObserver] | 读取 | 用于 :class:IntersectionObserver 的构造函数引用。 |
ResizeObserver | type[ResizeObserver] | 读取 | 用于 :class:ResizeObserver 的构造函数引用。 |
MessagePort | type[MessagePort] | 读取 | 用于 :class:MessagePort 的构造函数引用。 |
MessageChannel | type[MessageChannel] | 读取 | 用于 :class:MessageChannel 的构造函数引用。 |
BroadcastChannel | type[BroadcastChannel] | 读取 | 用于 :class:BroadcastChannel 的构造函数引用。 |
crypto | "Crypto" | 读取 | 返回每个窗口的 :class:Crypto 对象存根。 |
Crypto | type["Crypto"] | 读取 | 用于 :class:Crypto 的构造函数引用。 |
performance | "Performance" | 读取 | 返回每个窗口的 :class:Performance 对象。 |
Performance | type["Performance"] | 读取 | 用于 :class:Performance 的构造函数引用。 |
frames | "Window" | 读取 | 返回 self — 无头上下文没有框架子项 (WHATWG HTML §7.7.1)。 |
length | int | 读取 | 浏览上下文子框架的数量;在无头模式下始终为 0 (WHATWG HTML §7.7.1)。 |
is_secure_context | bool | 读取 | 无头上下文被视为安全的(Secure Contexts §2)。 |
crossorigin_isolated | bool | 读取 | 始终 False — headless environment has no cross-origin isolation(WHATWG HTML §7.2.2)。 |
origin_agent_cluster | bool | 读取 | 始终 False — headless environment has no origin-keyed agent clusters(WHATWG HTML §7.2.2)。 |
location_bar | "BarProp" | 读取 | 位置栏可见性存根;始终不可见(WHATWG HTML §7.7.3)。 |
menu_bar | "BarProp" | 读取 | 菜单栏可见性存根;始终不可见(WHATWG HTML §7.7.3)。 |
personal_bar | "BarProp" | 读取 | 个人栏可见性存根;始终不可见(WHATWG HTML §7.7.3)。 |
scroll_bars | "BarProp" | 读取 | 滚动条可见性存根;始终不可见(WHATWG HTML §7.7.3)。 |
status_bar | "BarProp" | 读取 | 状态栏可见性存根;始终不可见(WHATWG HTML §7.7.3)。 |
tool_bar | "BarProp" | 读取 | 工具栏可见性存根;始终不可见 (WHATWG HTML §7.7.3). |
navigation | `` | 读取 | 导航 API — 无头存根,始终 None。 |
locationbar | "BarProp" | 读取 | :attr:location_bar 的别名 — IDL camelCase 名称(WHATWG HTML 第 7.3.4 节)。 |
menubar | "BarProp" | 读取 | :attr:menu_bar 的别名 — IDL camelCase 名称(WHATWG HTML 第 7.3.4 节)。 |
personalbar | "BarProp" | 读取 | 别名为 :attr:personal_bar — IDL camelCase 名称(WHATWG HTML §7.3.4)。 |
scrollbars | "BarProp" | 读取 | 别名为 :attr:scroll_bars — IDL camelCase 名称(WHATWG HTML §7.3.4)。 |
statusbar | "BarProp" | 读取 | 别名为 :attr:status_bar — IDL camelCase 名称(WHATWG HTML §7.3.4)。 |
toolbar | "BarProp" | 读取 | 别名为 :attr:tool_bar — IDL camelCase 名称(WHATWG HTML §7.3.4)。 |
fetch | None | 读取 | 始终 None — 在无头模式下,Fetch API(网络)不可用。 |
screen_width | int | 读取 | 总屏幕宽度为 CSS 像素(无头存根:0)。 |
screen_height | int | 读取 | 总屏幕高度为 CSS 像素(无头存根:0)。 |
trusted_types | None | 读取 | 始终 None — Trusted Types API 在无头模式下未实现。 |
external | "_External" | 读取 | 遗留的 window.external 对象存根 (WHATWG HTML §11.5). |
speech_synthesis | None | 读取 | 始终 None — Web Speech API 在无头模式下不可用。 |
caches | None | 读取 | 始终 None — Cache Storage API 在无头模式下不可用。 |
index_db | None | 读取 | 始终 None — IndexedDB 在无头模式下不可用。 |
scheduler | `` | 读取 | 始终 None — 在无头模式下没有 Prioritized Task Scheduling API。 |
pub_key_credential | `` | 读取 | 始终 None — 在无头模式下没有 WebAuthn API。 |
cookie_store | `` | 读取 | 始终 None — 在无头模式下没有 Cookie Store API。 |
text_decoder | `` | 读取 | 始终 None — TextDecoder 在无头模式下未通过 Window IDL 暴露。 |
text_encoder | `` | 读取 | 始终 None — TextEncoder 在无头模式下未通过 Window IDL 暴露。 |
onunhandledrejection | `Callable[[object], object] | None` | 读取 |
方法
| 签名 | 描述 |
|---|---|
__init__(document: "Document") | Calls init(document) 在此 Window 实例上。 |
queue_microtask(callback: "Callable[[], None]") | Schedule callback 作为通过 WindowEventLoop 接口的微任务。 |
| `structured_clone(value: object, transfer: list | None)→object` |
print() | 请求打印对话框(在无头模式下为无操作)。 |
stop() | 停止加载当前文档(在无头模式下为无操作)。 |
scroll(x: float, y: float) | 将视口滚动到绝对位置 — 在无头模式下不执行任何操作。 |
scroll_to(x: float, y: float) | 将视口滚动到绝对位置 — 在无头模式下不执行任何操作。 |
scroll_by(x: float, y: float) | 按相对增量滚动视口 — 在无头模式下不执行任何操作。 |
set_timeout(callback: "Callable[..., object]", delay: int) → int | 将一次性计时器回调排入队列并返回其句柄。 |
| `clear_timeout(id: int | None)` |
set_interval(callback: "Callable[..., object]", delay: int) → int | 排队一个循环计时器回调并返回其句柄。 |
| `clear_interval(id: int | None)` |
request_animation_frame(callback: "Callable[[float], object]") → int | 请求动画帧回调(无操作存根;返回 0)。 |
| `cancel_animation_frame(id: int | None)` |
| `request_idle_callback(callback: “Callable[…, object]”, options: object | None)→int` |
| `cancel_idle_callback(id: int | None)` |
open(url: str, target: str, features: str) | 根据 WHATWG HTML §8.8.2 的规定,提供无操作浏览上下文命令存根。 |
close() | 根据 WHATWG HTML §8.8.1 的无操作浏览上下文命令存根。 |
focus() | 无操作浏览上下文命令存根。 |
blur() | 无操作浏览上下文命令存根。 |
alert(message: str) | 根据 WHATWG HTML §8.5.1 的无操作对话框存根。 |
confirm(message: str) → bool | 根据 WHATWG HTML §8.5.1 的无操作对话存根。 |
prompt(message: str, default: str) → `str | None` |
| `get_computed_style(element: “Element”, pseudo_elt: str | None)→“ComputedStyleDeclaration”` |
match_media(query: str) → "MediaQueryList" | 返回一个 :class:MediaQueryList for query. |
get_selection() → "Selection" | 返回此窗口文档的 :class:~aspose_html.dom.Selection。 |
post_message(message: object, target_origin: str, transfer: object) | 空操作存根 — 不支持无头交付语义 (WHATWG HTML §7.7.5)。 |
find(aString: str, aCaseSensitive: bool, aBackwards: bool, aWrapAround: bool, aWholeWord: bool, aSearchInFrames: bool, aShowDialog: bool) → bool | 始终返回 False — 不支持无头页面内查找 (WHATWG HTML §9.2.6)。 |
move_to(x: int, y: int) | 空操作存根 — 无头模式没有操作系统窗口可重新定位 (CSSOM View §11)。 |
move_by(dx: int, dy: int) | 空操作存根 — 无头模式没有操作系统窗口可移动 (CSSOM View §11)。 |
resize_to(width: int, height: int) | 空操作存根 — headless 没有可调整大小的 OS 窗口 (CSSOM View §11). |
resize_by(dwidth: int, dheight: int) | 空操作存根 — headless 没有可调整大小的 OS 窗口 (CSSOM View §11). |
atob(data: str) → str | 解码 base64 编码的 ASCII 字符串 (WHATWG Infra §1 / HTML §8.2.3). |
btoa(data: str) → str | 将字符串编码为 base64 (WHATWG Infra §1 / HTML §8.2.3). |
report_error(e: object) | 在无头模式下不执行任何操作。 |
add_event_listener(type: str, listener: Callable, capture: bool, once: bool) | Register listener 针对事件的 type. |
remove_event_listener(type: str, listener: Callable, capture: bool) | 注销先前已注册的监听器。 |
dispatch_event(event: "Event") → bool | Dispatch event 通过祖先树。 |