23
29

More than 5 years have passed since last update.

ブラウザバック禁止

Posted at

小ネタ。
少し前に諸事情で対応が必要になったので。

window.location.hash="#noback";
window.onhashchange=function(){
    window.location.hash="#noback";
}

http://hidari-lab.hatenablog.com/entry/2015/03/02/212818
に詳しいです。

URLにhash(URLの後ろにくっつく#HogeHogeみたいな文字列で、ページ内リンクなんかに使われてる)をつけることで別ページへの遷移として履歴に残して、他のページに戻れなくしてしまう方法。

ブラウザの「戻る」ボタン長押しなどで、履歴を直接たどるのは止められないけど、無意識にブラウザバックする人は止められるかなと。

23
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
29