Skip to content

Instantly share code, notes, and snippets.

@thatisuday
Created December 24, 2020 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thatisuday/93f7d6b198f1b05d99c1c7b81ab97287 to your computer and use it in GitHub Desktop.
Save thatisuday/93f7d6b198f1b05d99c1c7b81ab97287 to your computer and use it in GitHub Desktop.
A simple Electron window (HTML) page.
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<title>My Electron App</title>
<style>
body {
padding: 50px;
font-size: 14px;
background-color: #eee;
font-family: sans-serif;
text-align: center;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<button id='btn'>Click to open a photo</button>
<script>
const { ipcRenderer } = require( 'electron' );
document.getElementById( 'btn' ).onclick = function() {
ipcRenderer.send( 'app:display-image' );
console.log( '[message sent]', 'app:display-image' );
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment