Activate Lightbox when visitor attempts to leave the site

Trying to add some functionality that triggers a specific lightbox to open when the visitor attempts to leave the site (eg. mouses out of the site window to close the tab or navigate elsewhere). Any ideas?

Use onLogout() for your purpose.

All I can find with this command relates to a user logging out of their account. Does not seem to work with the mouse moving out of the view panel.

I’ve been trying to use:

wixWindow.addEventListener("mouseleave", function (event) {
        wixWindow.openLightbox("Announcement Lightbox");
    });

but addEventListener does not seem to exist (has the red squiggly underneath).

Funnily enough, this code snippet was recommended to me by ChatGPT. Even specific to Wix Velo.

To be able to use your …
wixWindow . addEventListener ( “mouseleave” , function ( event ){ wixWindow . openLightbox ( “Announcement Lightbox” );});
…code, you will need to use either a CUSTOM-ELEMENT, or an HTML-Component.

Maybe someoneelse has a better idea how to solve your issue.
Wix dosn’t provide all options, regarding your issue.