glowingbear-mainbox/electron-start.html

42 lines
1.3 KiB
HTML
Raw Permalink Normal View History

2016-04-03 13:47:38 +02:00
<!DOCTYPE html>
<html>
<head>
2016-04-03 13:47:38 +02:00
<meta charset="utf-8">
<script>
onload = function() {
2016-04-03 13:47:38 +02:00
const ipc= require('electron').ipcRenderer;
const remote = require('electron').remote;
const nativeImage = require('electron').nativeImage;
2016-05-11 11:38:07 +02:00
const shell = require('electron').shell;
2016-04-03 13:47:38 +02:00
var webview = document.getElementById("glowingbear");
2016-04-03 13:47:38 +02:00
var handleconsole = function(e) {
console.log("webview: " + e.message);
}
2016-04-03 13:47:38 +02:00
var handlenewwindow = function(e) {
2016-05-11 11:38:07 +02:00
shell.openExternal(e.url);
2016-04-03 13:47:38 +02:00
}
var handletitleset = function(e) {
document.title = e.title;
}
webview.addEventListener("console-message", handleconsole);
webview.addEventListener("new-window", handlenewwindow);
webview.addEventListener("page-title-set", handletitleset);
ipc.on('openDevTools', function() {
setTimeout(function() { webview.openDevTools(); }, 0 );
});
2016-04-03 13:47:38 +02:00
ipc.on('browser-window-focus', function() {
setTimeout(function() { webview.focus(); }, 0);
setTimeout(function() { webview.executeJavaScript("document.getElementById(\"sendMessage\").focus();") }, 0);
});
}
</script>
</head>
<body>
<webview preload="electron-globals.js" id="glowingbear" src="index.html" style="position:fixed; top:0; left:0; bottom:0; right:0;"></webview>
</body>
</html>