WebView API (Page Control)
All operations target a window_id (there is no separate webview handle). WebViewSettings is documented field by field in the Window API, so here we focus on what you can still call after creation.
Navigation & Scripts
Navigate to URL (navigate_to_url)
Make the page in the specified window open another address (http, file, custom protocol, etc.).
int32_t navigate_to_url(uint32_t window_id, const char* url, const char* headers_json);Parameters:
window_iduint32_t- target window idurlstring- the address to navigate toheaders_jsonstring(optional) - request headers as a JSON object, e.g.{"Authorization":"Bearer xxx","X-Custom":"value"}. PassingNULLor an empty string behaves the same as the original API (changed in 2.2)
Go Back (webview_go_back) v2.4
int32_t webview_go_back(uint32_t window_id);- Parameter:
window_iduint32_t, as returned bycreate_webview_windoworcreate_borderless_webview_window. - Return value:
1means the command has entered the message queue,0means the parameter is invalid or the message queue is unavailable.
Go Forward (webview_go_forward) v2.4
int32_t webview_go_forward(uint32_t window_id);- Parameter:
window_iduint32_t, as returned bycreate_webview_windoworcreate_borderless_webview_window. - Return value:
1means the command has entered the message queue,0means the parameter is invalid or the message queue is unavailable.
Query Whether Back Is Possible (webview_can_go_back) v2.4
int32_t webview_can_go_back(uint32_t window_id);- Parameter:
window_iduint32_t, target window id. - Return value:
1means back is possible,0means it is not possible or the window does not exist.
Query Whether Forward Is Possible (webview_can_go_forward) v2.4
int32_t webview_can_go_forward(uint32_t window_id);- Parameter:
window_iduint32_t, target window id. - Return value:
1means forward is possible,0means it is not possible or the window does not exist.
Usage Notes
- Back/forward operates on the WebView native history stack and also works for history entries created by
window.history.pushState. webview_can_go_back/webview_can_go_forwardare synchronous queries, suitable for updating toolbar button states.- When a page has just been created and has no history,
webview_can_go_back()usually returns0; query afterwindow-createdorwebview-did-finish-load. - Do not call these synchronous query APIs from inside a JadeView event callback to avoid deadlocking the event-loop thread.
uint32_t win = create_webview_window("https://example.com/page-a", 0, NULL, NULL);
/* Wait for webview-did-finish-load before calling */
if (webview_can_go_back(win)) {
webview_go_back(win);
}
if (webview_can_go_forward(win)) {
webview_go_forward(win);
}Reload Page (reload_webview_window)
Reload the current page, similar to the user pressing F5.
int32_t reload_webview_window(uint32_t window_id);Parameters:
window_iduint32_t- target window id
Execute JavaScript (execute_javascript)
Inject and execute a piece of JavaScript into the page.
If you need the execution result, retrieve it via the javascript-result event and the like (see Event Types).
int32_t execute_javascript(uint32_t window_id, const char* script);Parameters:
window_iduint32_t- target window idscriptstring- the JavaScript code to execute
Return value:
> 0- the returned value is a request id, not the JS execution result; the actual JS result must be retrieved by this id via thejavascript-resultevent0-scriptisNULL(nothing was submitted for execution)
Set Page Zoom (set_webview_zoom)
Zoom the whole page, e.g. 1.0 is 100% and 1.5 is 150%.
int32_t set_webview_zoom(uint32_t window_id, double level);Parameters:
window_iduint32_t- target window idleveldouble- zoom ratio
Clear Browsing Data (clear_browsing_data) v2.2
Clear all browsing data (Cookies / cache / LocalStorage, etc.) of the specified window.
int32_t clear_browsing_data(uint32_t window_id);- Parameter:
window_iduint32_t - Return value: only indicates that the request was submitted (asynchronous, fire-and-forget); always returns
1and does not reflect whether the browsing data was actually cleared
Security Control
Set Content Protection (set_content_protection)
When enabled, some screenshot/screen-recording software has a harder time capturing the window content (the effect varies by system and capture method).
int32_t set_content_protection(uint32_t window_id, int32_t content_protection);Parameters:
window_iduint32_t- target window idcontent_protectionint32_t- non-0enables protection,0disables protection
DevTools v2.2
DevTools must be enabled when creating the window (the
enable_devmodparameter ofJadeView_init).
Open DevTools (open_devtools) v2.2
int32_t open_devtools(uint32_t window_id);- Parameter:
window_iduint32_t - Return value: only indicates that the request was submitted (asynchronous, fire-and-forget); always returns
1and does not reflect whether DevTools actually opened
Close DevTools (close_devtools) v2.2
int32_t close_devtools(uint32_t window_id);- Parameter:
window_iduint32_t - Return value: only indicates that the request was submitted (asynchronous, fire-and-forget); always returns
1and does not reflect whether DevTools actually closed - Platform note: invoked on all platforms; on Windows / WebView2 it is a no-op (no error, still returns
1)
Query Whether DevTools Is Open (is_devtools_open) v2.2
int is_devtools_open(uint32_t window_id);- Parameter:
window_iduint32_t - Return value:
1= open,0= not open
Printing
Print WebView Content (jade_print)
Open the standard system print dialog to print the current WebView content.
int32_t jade_print(uint32_t window_id);Parameters:
window_iduint32_t- target window id
Return value:
- only indicates that the request was submitted (asynchronous, fire-and-forget); always returns
1and does not reflect whether the print dialog actually appeared or printing succeeded
Available on both Windows (WebView2) and Linux (WebKitGTK) — under the hood it uses wry's cross-platform webview.print().
Runtime Information
Get WebView Version (get_webview_version)
Read out the version number of the Microsoft WebView2 runtime installed on the local machine (not the JadeView version). It is written into buffer (UTF-8 + \0).
int32_t get_webview_version(char* buffer, size_t buffer_size);Consistent with the description in the Tools API.