index.html 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <div id="window-label"></div>
  5. <div id="container"></div>
  6. <div id="response"></div>
  7. <script>
  8. var windowLabel = window.__TAURI__.currentWindow.label
  9. var windowLabelContainer = document.getElementById('window-label')
  10. windowLabelContainer.innerHTML = 'This is the ' + windowLabel + ' window.'
  11. var responseContainer = document.getElementById('response')
  12. window.__TAURI__.event.listen('window://' + windowLabel, function (event) {
  13. responseContainer.innerHTML = 'Got ' + JSON.stringify(event)
  14. })
  15. var container = document.getElementById('container')
  16. for (var index in window.__TAURI__.windows) {
  17. const label = window.__TAURI__.windows[index].label
  18. if (label === windowLabel) {
  19. continue;
  20. }
  21. const button = document.createElement('button')
  22. button.innerHTML = 'Send message to ' + label
  23. button.addEventListener('click', function () {
  24. window.__TAURI__.event.emit('window://' + label, 'message from ' + windowLabel)
  25. })
  26. container.appendChild(button)
  27. }
  28. </script>
  29. </body>
  30. </html>