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.


Make the page in the specified window open another address (http, file, custom protocol, etc.).

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

Parameters:

  • window_id uint32_t - target window id
  • url string - the address to navigate to
  • headers_json string (optional) - request headers as a JSON object, e.g. {"Authorization":"Bearer xxx","X-Custom":"value"}. Passing NULL or an empty string behaves the same as the original API (changed in 2.2)

Go Back (webview_go_back) v2.4

C
int32_t webview_go_back(uint32_t window_id);
  • Parameter: window_id uint32_t, as returned by create_webview_window or create_borderless_webview_window.
  • Return value: 1 means the command has entered the message queue, 0 means the parameter is invalid or the message queue is unavailable.

Go Forward (webview_go_forward) v2.4

C
int32_t webview_go_forward(uint32_t window_id);
  • Parameter: window_id uint32_t, as returned by create_webview_window or create_borderless_webview_window.
  • Return value: 1 means the command has entered the message queue, 0 means the parameter is invalid or the message queue is unavailable.

Query Whether Back Is Possible (webview_can_go_back) v2.4

C
int32_t webview_can_go_back(uint32_t window_id);
  • Parameter: window_id uint32_t, target window id.
  • Return value: 1 means back is possible, 0 means it is not possible or the window does not exist.

Query Whether Forward Is Possible (webview_can_go_forward) v2.4

C
int32_t webview_can_go_forward(uint32_t window_id);
  • Parameter: window_id uint32_t, target window id.
  • Return value: 1 means forward is possible, 0 means 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_forward are synchronous queries, suitable for updating toolbar button states.
  • When a page has just been created and has no history, webview_can_go_back() usually returns 0; query after window-created or webview-did-finish-load.
  • Do not call these synchronous query APIs from inside a JadeView event callback to avoid deadlocking the event-loop thread.
C
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.

C
int32_t reload_webview_window(uint32_t window_id);

Parameters:

  • window_id uint32_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).

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

Parameters:

  • window_id uint32_t - target window id
  • script string - 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 the javascript-result event
  • 0 - script is NULL (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%.

C
int32_t set_webview_zoom(uint32_t window_id, double level);

Parameters:

  • window_id uint32_t - target window id
  • level double - zoom ratio

Clear Browsing Data (clear_browsing_data) v2.2

Clear all browsing data (Cookies / cache / LocalStorage, etc.) of the specified window.

C
int32_t clear_browsing_data(uint32_t window_id);
  • Parameter: window_id uint32_t
  • Return value: only indicates that the request was submitted (asynchronous, fire-and-forget); always returns 1 and 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).

C
int32_t set_content_protection(uint32_t window_id, int32_t content_protection);

Parameters:

  • window_id uint32_t - target window id
  • content_protection int32_t - non-0 enables protection, 0 disables protection

DevTools v2.2

DevTools must be enabled when creating the window (the enable_devmod parameter of JadeView_init).

Open DevTools (open_devtools) v2.2

C
int32_t open_devtools(uint32_t window_id);
  • Parameter: window_id uint32_t
  • Return value: only indicates that the request was submitted (asynchronous, fire-and-forget); always returns 1 and does not reflect whether DevTools actually opened

Close DevTools (close_devtools) v2.2

C
int32_t close_devtools(uint32_t window_id);
  • Parameter: window_id uint32_t
  • Return value: only indicates that the request was submitted (asynchronous, fire-and-forget); always returns 1 and 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

C
int is_devtools_open(uint32_t window_id);
  • Parameter: window_id uint32_t
  • Return value: 1 = open, 0 = not open

Printing

Open the standard system print dialog to print the current WebView content.

C
int32_t jade_print(uint32_t window_id);

Parameters:

  • window_id uint32_t - target window id

Return value:

  • only indicates that the request was submitted (asynchronous, fire-and-forget); always returns 1 and does not reflect whether the print dialog actually appeared or printing succeeded

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).

C
int32_t get_webview_version(char* buffer, size_t buffer_size);

Consistent with the description in the Tools API.