Guest User

Untitled

a guest
Jan 18th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. history.pushState(null, null, location.href);
  2. window.onpopstate = function(event) {
  3. history.go(1);
  4. };
  5.  
  6. window.onload = function() {
  7. if (typeof history.pushState === "function") {
  8. history.pushState("jibberish", null, null);
  9. window.onpopstate = function() {
  10. history.pushState('newjibberish', null, null);
  11. // Handle the back (or forward) buttons here
  12. // Will NOT handle refresh, use onbeforeunload for this.
  13. };
  14. }
  15. else {
  16. var ignoreHashChange = true;
  17. window.onhashchange = function() {
  18. if (!ignoreHashChange) {
  19. ignoreHashChange = true;
  20. window.location.hash = Math.random();
  21. // Detect and redirect change here
  22. // Works in older FF and IE9
  23. // * it does mess with your hash symbol (anchor?) pound sign
  24. // delimiter on the end of the URL
  25. }
  26. else {
  27. ignoreHashChange = false;
  28. }
  29. };
  30. }
  31. };
  32.  
  33. $(document).ready(function(){
  34. removeBack();
  35. });
  36. function removeBack(){
  37. history.pushState(null, null, '');
  38. window.addEventListener('popstate', function () {
  39. //тут какие то другие действия пишем если надо
  40. history.pushState(null, null, '');
  41. });
  42. };
  43. }
Add Comment
Please, Sign In to add comment