跳到主要内容

WebView API

所有操作都针对 window_id(没有单独的 webview 句柄)。WebViewSettings核心 API 里按字段说明过,这里侧重创建之后还能调什么。


用途:当前窗口里的页面跳转到新 URL

int32_t navigate_to_url(uint32_t window_id, const char* url);

reload_webview_window

用途重新加载当前页。

int32_t reload_webview_window(uint32_t window_id);

execute_javascript

用途:在页面环境里跑一段 JS。返回值只表示任务有没有排队成功;真正的脚本返回值通过 javascript-result 等事件回来(见 事件类型)。

int32_t execute_javascript(uint32_t window_id, const char* script);

set_webview_zoom

用途:整页缩放比例1.0 = 100%。

int32_t set_webview_zoom(uint32_t window_id, double level);

set_content_protection

用途:降低窗口被截图、录屏采集到的概率(取决于 Windows 版本和对方用的采集接口)。

int32_t set_content_protection(uint32_t window_id, int32_t content_protection);

get_webview_version

用途:读出本机安装的 Microsoft WebView2 运行时版本号(不是 JadeView 版本)。写入 buffer(UTF-8 + \0)。

int32_t get_webview_version(char* buffer, size_t buffer_size);

工具 API 中的说明一致。