Link Based Redirect (Confirmation)

Add a safety layer to navigation. This script asks the user to confirm their intent before following a link, preventing accidental clicks or warning of external content.

Try clicking the link below:

Go to Google.com

Copy the Script

<script>
function confirmExit() {
    return confirm("You are about to leave this website. Continue?");
}
</script>

<a href="http://example.com" onclick="return confirmExit()">External Link</a>

Frequently Asked Questions

It's commonly used by banks or secure sites to warn users they are visiting an external website, or to confirm actions like 'Delete Account' before navigating to the handler.

The standard `confirm()` box cannot be styled. To have a custom look, you must prevent the default link action (`e.preventDefault()`) and show a custom HTML modal instead.

If the function returns `false`, the link click is canceled, and the user stays on the current page.