Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- history.pushState(null, null, location.href);
- window.onpopstate = function(event) {
- history.go(1);
- };
- window.onload = function() {
- if (typeof history.pushState === "function") {
- history.pushState("jibberish", null, null);
- window.onpopstate = function() {
- history.pushState('newjibberish', null, null);
- // Handle the back (or forward) buttons here
- // Will NOT handle refresh, use onbeforeunload for this.
- };
- }
- else {
- var ignoreHashChange = true;
- window.onhashchange = function() {
- if (!ignoreHashChange) {
- ignoreHashChange = true;
- window.location.hash = Math.random();
- // Detect and redirect change here
- // Works in older FF and IE9
- // * it does mess with your hash symbol (anchor?) pound sign
- // delimiter on the end of the URL
- }
- else {
- ignoreHashChange = false;
- }
- };
- }
- };
- $(document).ready(function(){
- removeBack();
- });
- function removeBack(){
- history.pushState(null, null, '');
- window.addEventListener('popstate', function () {
- //тут какие то другие действия пишем если надо
- history.pushState(null, null, '');
- });
- };
- }
Add Comment
Please, Sign In to add comment