title: How do I catch the onclose (onbeforeunload) event of a child window in Vue.js?
body: <p>I have tried to make a function in Vue.js, that open a new window in Chrome. I need to capture the onclose or onbeforeunload event of the window from the same component in Vue that opened the window. I try to implement it in this way:</p>
  
  <pre><code>...
  methods: {
      gitConnet(){
              var child = window.open("https://www.google.it", '_blank', 'fullscreen=no,height=600,width=800,top=100,location=no,titlebar=0');
  
              child.onclose = function(){ console.log('Child window onclose closed'); };
  
              child.onbeforeunload = function(){ console.log('Child window onbeforeunload closed'); };
          }
  }
  ...
  </code></pre>
  
  <p>With this code I'm able to open the new window, but when I close the window, I don't see any message in the console. I have also tried to insert the child variable in the data property of the component, but nothing is changed.</p>
  
  <p>Please, someone could help me to catch the onclose event of the window inside the Vue component.</p>
  
  <p>Thanks in advance.</p>