Last active
August 29, 2015 14:25
-
-
Save RyoSugimoto/ed1be9468f735f3712b4 to your computer and use it in GitHub Desktop.
HTML5のHistory APIを利用して、ブラウザの「戻る」を無効化する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// このコードはjQueryを仕様しています。 | |
if(window.history && window.history.pushState) { | |
var stateName = 'samePage'; | |
history.pushState(stateName, null, null); | |
$(window).on('popstate', function (e) { | |
if (history.state === stateName) { | |
alert(history.state); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment