WebView (웹뷰) Widget Control
This page lists the Widget Control (Property · Method · Event) entries you use to control the WebView widget from a script. To learn about the widget itself and how to use it, visit WebView.
In the examples below, webviewID is the name (ID) you gave the WebView widget on the canvas. In scripts, you access members in the form widgetID.member.
Widget Control summary
| Widget Control | Kind | Signature | Description |
|---|---|---|---|
value | Property | webviewID.value | Content the WebView loads (URL, asset path, or HTML data). Read/write, string |
userAgent | Property | webviewID.userAgent | Custom User-Agent appended after the default User-Agent. Read/write, string |
embedInParentScroll | Property | webviewID.embedInParentScroll | Whether trackpad and wheel scrolling passes through to the parent scroll view (macOS only). Read/write, boolean |
setValue | Method | webviewID.setValue(s) | Sets the content to load. Same as assigning to value |
runJavaScript | Method | webviewID.runJavaScript(funcName, args, callback) | Runs JavaScript in the loaded page |
asyncRunJavaScript | Method | webviewID.asyncRunJavaScript(funcName, args, callback) | Runs JavaScript asynchronously and waits for the result |
sendDataToWeb | Method | webviewID.sendDataToWeb(funcName, args, callback) | Calls a JavaScript function in the page by name and passes data to it |
onReceiveData | Method | webviewID.onReceiveData(callback) | Registers a callback that receives data the page pushes to the host |
addJavaScriptHandler | Method | webviewID.addJavaScriptHandler(handlerName, callback) | Registers a JavaScript handler the page can call by name |
isCreatedNewWindow | Method | webviewID.isCreatedNewWindow(result) | Sets whether links may open in a new window |
injectGlow | Method | webviewID.injectGlow(json) | Overlays an animated glow effect on the loaded page |
removeGlow | Method | webviewID.removeGlow() | Removes the glow effect added by injectGlow |
onFinished | Event | webviewID.onFinished = (value) => { ... } | Fires when the current page finishes loading |
onShouldOverrideUrl | Event | webviewID.onShouldOverrideUrl = (value) => { ... } | Fires when the page sends a message to the host over the hybrid:// bridge |
Property
value
The content the WebView loads. It is interpreted according to the widget's type — URL, asset path, or inline HTML. Assign a value to reload the WebView with the new content.
- Kind: Property (read/write)
- Type: string
- Returns(get): The content string currently loaded
Example
webviewID.value = "https://example.com";
let current = webviewID.value;
userAgent
A custom User-Agent appended after the default User-Agent string.
- Kind: Property (read/write)
- Type: string
- Returns(get): The appended custom User-Agent string
Example
webviewID.userAgent = "MyApp/1.0";
embedInParentScroll
Whether trackpad or mouse-wheel scrolling over the WebView passes through to the parent scroll view (macOS only). Set it to true after the WebView is created and the change applies immediately. Other platforms ignore it.
- Kind: Property (read/write)
- Type: boolean
- Returns(get): Whether scrolling passes through to the parent (boolean). Defaults to
false
Example
webviewID.embedInParentScroll = true;
Method
setValue
Sets the content for the WebView to load. This is the same as assigning to the value property, and the string is interpreted according to the widget's type — URL, asset path, or HTML data.
- Parameters
s(string): Content to load (URL, asset path, or HTML data)
- Returns: None
Example
webviewID.setValue("https://example.com");
runJavaScript
Runs JavaScript in the loaded page. The call takes the form funcName(args), with args encoded as JSON. If args is empty or omitted, funcName is evaluated as-is — so you can pass a raw expression. If the page hasn't finished loading, the call is queued and runs once the page is ready.
- Parameters
funcName(string): Name of the JavaScript function to run, or an expressionargs: Arguments to pass to the function (JSON-encoded)callback(optional): Callback that receives the result{success, data, error}
- Returns: None — the result goes to
callback
Example
webviewID.runJavaScript("window.someFunction", { value: 100 }, function() {});
asyncRunJavaScript
Runs JavaScript asynchronously and waits for the result. When args is given, funcName is treated as a function body whose return value is awaited. Otherwise funcName is evaluated as an expression. If the page hasn't finished loading, the call is queued and runs once the page is ready.
- Parameters
funcName(string): JavaScript function body or expressionargs: Arguments used in the function bodycallback(optional): Callback that receives the result{success, data, error}
- Returns: None — the result goes to
callback
Example
webviewID.asyncRunJavaScript("myFunc(param);", { "param": data });
sendDataToWeb
Calls a JavaScript function in the loaded page and passes args to it. The call takes the form funcName(args), with args encoded as JSON. Pass an empty or omitted map and funcName is evaluated as-is. If the page hasn't finished loading, the call is queued and runs once the page is ready.
- Parameters
funcName(string): Name of the JavaScript function to callargs: Arguments to pass to the function (JSON-encoded)callback(optional): Callback that receives the result{success, data, error}
- Returns: None — it completes asynchronously and the result goes to
callback
Example
webviewID.sendDataToWeb("window.someFunction", data, function() {});
onReceiveData
Registers a callback that receives data the loaded page pushes to the host. The callback is called with the message payload as its argument.
- Parameters
callback: Function that receives the data the page sent as its argument
- Returns: None
Example
webviewID.onReceiveData((data) => {
// data = the payload pushed by the page
});
addJavaScriptHandler
Registers a JavaScript handler the loaded page can call by name, through the page's host bridge. If the page hasn't finished loading, the registration is queued and applies once the page is ready.
- Parameters
handlerName(string): Name the page uses to call this handlercallback: Function called with the arguments the page passes in
- Returns: None
Example
webviewID.addJavaScriptHandler("onQuote", (args) => {
// args = the data sent by the page
});
isCreatedNewWindow
Controls whether the WebView may open links in a new window.
- Parameters
result(boolean):trueto allow new windows,falseto block them
- Returns: None
Example
webviewID.isCreatedNewWindow(true);
injectGlow
Overlays an animated glow effect on the loaded page, rendered as a Canvas 2D overlay. Pass the effect preset JSON as a string.
- Parameters
json(string): Glow effect preset (JSON string)
- Returns: None
Example
webviewID.injectGlow(JSON.stringify({ color: "#FF4CAF50", intensity: 0.8 }));
removeGlow
Removes the glow effect added by injectGlow.
- Parameters: None
- Returns: None
Example
webviewID.removeGlow();
Event
onFinished
Fires when the current page finishes loading.
- Kind: Event
- Handler arguments:
value- URL of the page that finished loading - Returns: None
Example
webviewID.onFinished = (value) => {
// value = the URL that finished loading
};
onShouldOverrideUrl
Fires when the loaded page sends a message to the host through a hybrid:// URL — the page-to-host IPC bridge. It lets the host intercept navigation and handle it directly.
- Kind: Event
- Handler arguments:
value- Decoded JSON payload sent by the page (object) - Returns: None
Example
webviewID.onShouldOverrideUrl = (value) => {
if (value["FunctionName"] == "OnReceiveData") {
let data = value["Data"];
}
};
Common Widget Control (all widgets)
Every widget can use the name-based common Widget Control (Method) such as setProperty, getProperty, and setStyleProperty. See the common reference doc (to be written).