Adding a Popup warning that you are leaving the website.

I would like a way to let people know that they are clicking a link that takes them to another website.

1 Like

You could add a lightbox that is hidden until they click on the link, and then put a “continue button” on the lightbox that will take them to that page. If you have multiple links that you need that function on you would need to figure out the coding to make the box disappear and then continue with the previously clicked link. I am sure there is a way to do that, otherwise you would have to make a lightbox for each link, not really practical if you have dozens of links though.

Hey, I am working on a similar issue. I want to inform my users via a popup notice that they’ll be forwarded to an external site when they click on an external link.

I have found the following code, but its not working:

import wixLocation from ‘wix-location’;

export function hoverBox2_click(event, $w) {
//Add your code for this event here:
$w(‘#box1’).hide(“fade”,100);
$w(‘#hoverBox1’).hide(“fade”,500);
$w(‘#button2’).hide(“fade”,500);
setTimeout(function () {wixLocation.to(“/amazon”),500});
}

Would appreciate any help.

Thanks in advance!

Did you change the element IDs (i.e., box1, hoverBox1, button 2) to match the IDs of the elements on your page? Read this article for more info.

@marlowe-shaeffer : Yes, the IDs are matching with each other.

Any update on this? I too am working on a similar issue. Our industry is required to notify users they are leaving the site to an external site, so definitely need the capability to do this if we are going to continue using wix :slight_smile:

If you have the site under your own domain, you can create a custom element that prompt an alert on beforeunload.
You should read these articles:

Google Search

https://support.wix.com/en/article/wix-editor-adding-a-custom-element-to-your-site

https://www.wix.com/velo/reference/$w/customelement/introduction

https://www.wix.com/velo/reference/$w/customelement/setattribute