I have found this really cool example online on how to run a WebView with Deno.
Is it possible to call a function insided your Deno App from an HTML button element placed inside the html template?
Take a look:
// Importing the webview library
import { WebView } from "https://deno.land/x/webview/mod.ts";
// Creating an HTML page
let html = `
<html>
<body>
<h1>Hello from deno v${Deno.version.deno}</h1>
<button type="button" onclick="test()">RUN TEST FUNCTION</button>
</body>
</html>
`;
function test() {
console.log('You really can do that!');
}
// Creating and configuring the webview
const webview = new WebView({
title: "Deno Webview Example",
url: "data:text/html," + html,
// url: 'https://www.google.com',
width: 768,
height: 1024,
resizable: true,
debug: true,
frameless: false
});
// Running the webview
webview.run();
To run this code you need to:
deno run -A --unstable webview.ts