-2
我開發一個頁面的Web應用程序,我想阻止後退按鈕,以防止音樂停止時,用戶的點擊吧!任何人都可以幫助我!在瀏覽器中阻止後退按鈕例如WhatsApp網絡
我開發一個頁面的Web應用程序,我想阻止後退按鈕,以防止音樂停止時,用戶的點擊吧!任何人都可以幫助我!在瀏覽器中阻止後退按鈕例如WhatsApp網絡
好,有完整的評價和測試,例如:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<script>
// Add actual page to history
history.pushState(null, null, location.pathname)
// Register back button click
window.onpopstate = function (e) {
// Prevent default action on back button click
e.preventDefault()
// Add actual page to history again
history.pushState(null, null, location.pathname)
}
</script>
</head>
<body>
</body>
</html>
我把它放在HTML頭它不工作,謝謝回覆! – Linvincible
您應該解釋您的解決方案做了什麼。只有代碼答案是不鼓勵的。 – Jens