Continue to website after popup triggered

For compliance purposes, I have to alert visitors whenever they click on a link that will navigate away from my site. The popup has a statement notifying the user that the link will take them away for my site, it has a button to cancel, and it has a button to continue. Without creating a specific popup for each external link I have, how would I pass the URL they are trying visit to the continue button of the popup?

Hello, and welcome to the forums.

Try this:

Make each external link trigger a JavaScript function. This function takes your link as the input. You can then replace the continue button’s link with the external link.

So, if your external link is “externallink.com”, put something like this instead:

<a onclick="passLink(externalLink)" id="link" href="externallink.com">TEXT</a>
<script>
const externalLink = document.getElementById.href('link');
</script>

Then, your JS function might look something like this:

function passLink(externalLink) {
document.getElementById.href('button-id') = externalLink;
} //Make sure your button has the id="button-id".

I haven’t tested this, and it probably needs some adjusting and probably has some semantic errors, but it’s a start.