javascriptを使用して、ブラウザの戻るボタンを押したときに前のページに戻らないようにする方法。どんな提案でも大歓迎です.**
感謝と敬意
バニスター
ありがたいことに、それは不可能です。ユーザーの [戻る] ボタンの動作を止めることはできませんが、技術的には、[戻る] ボタンを使用して移動しようとしても無意味になる回数だけ URL を変更できます。
// treat the URL changes as a non-external page (the page won't reload)
document.location.href += "?";
// Fill up the browser's history
for(var i = 0; i < 100; i++){
document.location.href += "a";
document.location.href = document.location.href.substring(0, document.location.href.length-1)
}
これにより、ブラウザの履歴が同じページで埋められ、実質的に戻るボタンが実際に使用できなくなります。
ページの読み込み時にこれを使用すると、ユーザーが配置したページから戻るときに停止します。
<script type = "text/javascript">
function changeHashOnLoad() {
window.location.href += "#";
setTimeout("changeHashAgain()", "50");
}
function changeHashAgain()
{
window.location.href += "1";
}
var storedHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != storedHash) {
window.location.hash = storedHash;
}
}, 50);
</script>
戻るボタンを押したときにユーザーのアクションを確認してみませんか?
何かのようなもの
window.onbeforeunload = function(){
return "Message here";
}
ユーザーが誤って戻る、進む、またはウィンドウを閉じて、URL を直接変更するのを防ぎます。