webview-guest-resize.html 563 B

123456789101112131415161718192021222324
  1. <html>
  2. <style>
  3. * {
  4. width: 100%;
  5. height: 100%;
  6. margin: 0;
  7. }
  8. </style>
  9. <body>
  10. <webview id="webview" nodeintegration src="resize.html"/>
  11. </body>
  12. <script type="text/javascript" charset="utf-8">
  13. const {ipcRenderer} = require('electron')
  14. const webview = document.getElementById('webview')
  15. webview.addEventListener('did-finish-load', () => {
  16. ipcRenderer.send('webview-loaded')
  17. }, {once: true})
  18. webview.addEventListener('resize', event => {
  19. ipcRenderer.send('webview-element-resize', event.newWidth, event.newHeight)
  20. }, false)
  21. </script>
  22. </html>