0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ブラウザの戻るボタンを押せなくする(ブラウザバック禁止)

Posted at

既出だとおもいますが、勉強になったのでメモがてら。

表題通り、ブラウザバックさせないようにするためには、履歴を残さないようにすればOK。
Location.replace() を使えば、ページを移動した履歴が残らないとのこと。

html 内に書くなら、onclickを使って下記通り。


<a href="javascript:void(0)" onclick="location.replace('https://xxxx')">ページをすすむ</a>

jsで書くなら下記通り。

$('.class').on('click', function () {
  window.location.replace(指定のURL);
});

##■参照
http://www.htmq.com/js/location_replace.shtml
https://syncer.jp/javascript-reference/location/replace

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?