import { Webview } from "https://deno.land/x/webview@0.7.5/mod.ts";
An instance of a webview window.
Examples
Local
import { Webview } from "../mod.ts";
const html = `
<html>
<body>
<h1>Hello from deno v${Deno.version.deno}</h1>
</body>
</html>
`;
const webview = new Webview();
webview.navigate(`data:text/html,${encodeURIComponent(html)}`);
webview.run();
Remote
import { Webview } from "../mod.ts";
const webview = new Webview();
webview.navigate("https://deno.land/");
webview.run();
Constructors
UNSAFE: Highly unsafe API, beware!
Creates a new webview instance from a webview handle.
Creates a new webview instance.
Example
import { Webview, SizeHint } from "../mod.ts";
// Create a new webview and change from the default size to a small fixed window
const webview = new Webview(true, {
width: 200,
height: 200,
hint: SizeHint.FIXED
});
webview.navigate("https://deno.land/");
webview.run();
Properties
Sets the native window size
Example
import { Webview, SizeHint } from "../mod.ts";
const webview = new Webview();
webview.navigate("https://deno.land/");
// Change from the default size to a small fixed window
webview.size = {
width: 200,
height: 200,
hint: SizeHint.FIXED
};
webview.run();
Sets the native window title
Example
import { Webview } from "../mod.ts";
const webview = new Webview();
webview.navigate("https://deno.land/");
// Set the window title to "Hello world!"
webview.title = "Hello world!";
webview.run();
UNSAFE: Highly unsafe API, beware!
An unsafe pointer to the webviews platform specific native window handle.
When using GTK backend the pointer is GtkWindow
pointer, when using Cocoa
backend the pointer is NSWindow
pointer, when using Win32 backend the
pointer is HWND
pointer.
Methods
Binds a callback so that it will appear in the webview with the given name as a global async JavaScript function. Callback arguments are automatically converted from json to as closely as possible match the arguments in the webview context and the callback automatically converts and returns the return value to the webview.
Binds a callback so that it will appear in the webview with the given name as a global async JavaScript function. Callback receives a seq and req value. The seq parameter is an identifier for using Webview.return to return a value while the req parameter is a string of an JSON array representing the arguments passed from the JavaScript function call.
Destroys the webview and closes the window along with freeing all internal resources.
Evaluates arbitrary JavaScript code. Evaluation happens asynchronously, also the result of the expression is ignored. Use Webview.bind | bindings if you want to receive notifications about the results of the evaluation.
Injects JavaScript code at the initialization of the new page. Every time the webview will open a the new page - this initialization code will be executed. It is guaranteed that code is executed before window.onload.
Returns a value to the webview JavaScript environment.
Runs the main event loop until it's terminated. After this function exits the webview is automatically destroyed.
Unbinds a previously bound function freeing its resource and removing it from the webview JavaScript context.