I'm trying to create a function that will show a prompt or modal when a user clicks on a link that will navigate the user to another site. For instance, the site I'm working on has links that go to outside medical sites.
I've tried several functions that show a prompt before the website closes, but not before the site navigates to a new site.
<a v-bind:href="item.url" target="_blank" class="evidence-links" rel="external nofollow">${item.title}</a>
function goodbye(e) {
if(!e) e = window
e.cancelBubble = true;
e.returnValue = 'You sure you want to leave?';
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
}
window.onbeforeunload=goodbye;
I wonder if target="_blank" prevents it from working? I'd like to keep that part, though.