title: How to trigger an alert, when the back button of the browser is passed in Vue.js
body: <p>I am trying to trigger an alert message once the user clicks the back button of a webpage. I am trying the following way:</p>
  <pre><code>import LeavePopup from '../../global/js/leave-popup';
  import ScrollTo from '../../global/js/scroll-to';
  import UrlHandler from '../../global/js/url-handler';
  
  import Vue from 'vue';
  import SignUpForm from '../../global/js/components/SignUpForm';
  import VideoPlayer from '../../global/js/components/VideoPlayer';
  import JustMadeMoney from '../../global/js/components/JustMadeMoney';
  import Carousel from 'vue-owl-carousel'
  
  document.addEventListener(&quot;DOMContentLoaded&quot;, function (event) {
      LeavePopup.bind('.modal');
      ScrollTo.bind();
      UrlHandler.handle('additionalParams');
  });
  
  new Vue({
      el: '#app',
  
      components: {
          VideoPlayer,
          SignUpForm,
          Carousel,
          JustMadeMoney
      },
      mounted() {
          // if back button is pressed
          window.onpopstate = function(event) {
            alert(&quot;Back button clicked&quot;);
          };
       }
  });
  </code></pre>
  <p>but currently nothing happens, how can I properly catch the click of the back button?</p>