title: vuejs run function after click back button in browser
body: <p>I load a component inside my vuejs page which is only visible after a certain button is pressed. But if the usere uses not the BACK BUTTON from the BROWSER, it doen't close my component and maked the &quot;original&quot; component visible, it jumes back to the page before.</p>
  <p>I need to prevent this behaviour.
  What I want to do is:</p>
  <ol>
  <li>Stop the &quot;GO BACK&quot; action</li>
  <li>Run a function instead</li>
  </ol>
  <p>I tried the following already and it runs the function when someone clicks the &quot;BACK BUTTON&quot; in the browser but it doesn't prevent the &quot;GO BACK ACTION&quot;.</p>
  <pre><code>mounted() {
      window.onpopstate = () =&gt; {
        this.closeDetailedView()
      }
    },
  </code></pre>
  <p>The closeDetailedView function does the folowing:</p>
  <pre><code>closeDetailedView() {
    this.$emit('closeDetailedView')
  },
  </code></pre>
  <p>Can someone help me?</p>
  <p>thanks</p>