title: Use JavaScript/jQuery to detect the Android back button
body: <p>Currently I want to make a function to detect the Android back button is pressed and do some stuff on it.</p>
  <ol>
  <li><p>The user opens the app, and clicks a button. This button lets the user to open a website.</p>
  </li>
  <li><p>The user fills in the information on page 2, and he/she wants to go back the previous page, and he/she clicks the back button on the Android phone.</p>
  </li>
  <li><p>The back button helps the user close the website and go back to my apps instead of back to page 1.</p>
  </li>
  </ol>
  <p>How can I do this with <a href="https://en.wikipedia.org/wiki/JQuery" rel="nofollow noreferrer">jQuery</a> or JavaScript to check the back button pressed by user? So that I can prevent the back button close the website, but redirect to another page.</p>
  <p><strong>Is there a way to detect the browser Android back button event? I want to override the default setting of the Android back button, and add some code inside.</strong></p>
  <p><em>PS: Not using Java.</em></p>
  <ul>
  <li>The back button on top (browser back button) can goes back to previous page.</li>
  <li>The back button on the bottom (back button phone) helps me close the website.</li>
  <li>I want make the bottom back button also goes back to the previous page.</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/qhOVn.jpg" rel="nofollow noreferrer">See this</a>.</p>