JSFiddle - React, Tailwind, and code Playground

by Suryar Praveen

HTML

<title>Back Button Example</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body style="text-align:center; padding:0;">
    <a href="#share" id="share">Share</a>
    <div class="share" style="display:none;">
        <h1>Test Page</h1>
        <p> Back button press please for control.</p>
    </div>
</body>

CSS

.share {background:#cccccc;}

JavaScript

$(document).ready(function() {
  $('body').on('click touch', '#share', function(e) {
    $('.share').fadeOut();
  });
});

// geri butonunu yakalama
window.onhashchange = function(e) {
  var oldURL = e.oldURL.split('#')[1];
  var newURL = e.newURL.split('#')[1];

  if (oldURL == 'share') {
    $('.share').fadeIn();
    e.preventDefault();
    return false;
  }
  console.log('old:'+oldURL+' new:'+newURL);
}