Safe Exit Button + Keyboard Shortcut
🚪 This tiny script adds an instant Safe Exit feature to your site. With one click (or keyboard shortcut), visitors are immediately redirected to a neutral page. No tracking, no storage, no dependencies — just fast and discreet.
Newbie setup: paste the code once, change the redirect URL if needed, and optionally place the button where you want it.
<!--
Safe Exit Button + Keyboard Shortcut
- No frameworks
- No cookies / no storage
- Click button OR press Esc to exit instantly
- Fully scoped (won’t affect site layout)
SETUP:
1) Paste everything below once (footer recommended).
2) Change EXIT_URL if you want.
3) Move or remove the button markup if needed.
-->
<style>
/* Scoped to .vs-safe-exit */
.vs-safe-exit{
position:fixed;
right:14px;
bottom:14px;
z-index:9999;
}
.vs-safe-exit button{
appearance:none;
border:0;
cursor:pointer;
font:700 13px/1 system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
padding:10px 12px;
border-radius:12px;
background:#111;
color:#fff;
}
.vs-safe-exit button:hover{
opacity:.9;
}
</style>
<div class="vs-safe-exit">
<button type="button" aria-label="Safe Exit">Exit</button>
</div>
<script>
(function(){
"use strict";
// ===== CONFIG =====
var EXIT_URL = "https://www.google.com"; // change if desired
var EXIT_KEYS = ["Escape"]; // keyboard shortcut(s)
function safeExit(){
// Replace history so Back button won’t return
window.location.replace(EXIT_URL);
}
// Button click
var btn = document.querySelector(".vs-safe-exit button");
if (btn){
btn.addEventListener("click", safeExit);
}
// Keyboard shortcut
document.addEventListener("keydown", function(e){
if (EXIT_KEYS.indexOf(e.key) !== -1){
safeExit();
}
});
})();
</script>
Comments (0)
No comments yet — be the first.