# Exit Intent Lightbox - Code

**URL:** <https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400>\
**Category:** Ask the community\
**Tags:** wix-studio, code\
**Created:** [April 22, 2025, 2:51am UTC](https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400 "2025-04-22T02:51:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ToThrive](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@ToThrive](https://forum.wixstudio.com/u/ToThrive)\
**Post date:** [April 22, 2025, 2:51am UTC](https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400/1 "2025-04-22T02:51:28Z")

</div>

Ive created code to show a pop up for exit intent.  
Ive reworked it a few times but it doesnt work.  
Can someone suggest where I am going wrong?

Originally i only put this code into the pages i wanted it to run on and it didnt work. SO I also added it into the lightbox code.

import wixWindow from ‘wix-window’;  
import wixSite from ‘wix-site’;  
wixSite.prefetchPageResources({  
lightboxes: [“Newsletter”]  
});  
$w.onReady(function () {  
$w(“#page1”).onMouseOut((event) =\> {  
if (event.clientY \<= 30) {  
wixWindow.openLightbox(“Newsletter”);  
}  
});  
});

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [April 22, 2025, 4:39am UTC](https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400/3 "2025-04-22T04:39:35Z")

</div>

Hi, @ToThrive !!

It worked correctly when I tried it on my end. 😇

```javascript
import wixWindowFrontend from "wix-window-frontend";
import wixSiteFrontend from "wix-site-frontend";

$w.onReady(function () {

    wixSiteFrontend.prefetchPageResources({
        lightboxes: ["MyLightBoxName"]
    });

    $w("#page1").onMouseOut((event) => {
        if (event.clientY <= 30) {
            wixWindowFrontend.openLightbox("MyLightBoxName");
        }
    });

});

```

I think the double quotation marks around `#page1` and `Newsletter` are not in half-width, which could be causing the error. It might have just been converted when pasted here. 🤔

---

<div class="post-metadata">

**Author:** ![ToThrive](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@ToThrive](https://forum.wixstudio.com/u/ToThrive)\
**Post date:** [April 23, 2025, 3:07am UTC](https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400/4 "2025-04-23T03:07:03Z")

</div>

Hi there! Great! I also tried again with another code, and it worked!  
Looks like the same as yours!

import wixSite from ‘wix-site’;  
import { openLightbox } from ‘wix-window-frontend’;

// Prefetch the lightbox so it loads instantly when triggered  
wixSite.prefetchPageResources({  
lightboxes: [‘Lightbox Name’]  
});

$w(‘#page1’).onMouseOut(() =\> {  
openLightbox(‘Lightbox Name’);  
});

---

<div class="post-metadata">

**Author:** ![onemoretime](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/onemoretime/32/104023_2.png) [@onemoretime](https://forum.wixstudio.com/u/onemoretime)\
**Post date:** [April 23, 2025, 3:46am UTC](https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400/5 "2025-04-23T03:46:59Z")

</div>

I’m glad to hear that! Personally, I hadn’t come across this kind of exit prevention idea before, so it was really educational for me 😙. Just one more thing—your code imports `wixSite`, but as far as I know, that module is deprecated. It might be better to update it to `wixSiteFrontend`, like in my code. 😇

---

<div class="post-metadata">

**Author:** ![ToThrive](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@ToThrive](https://forum.wixstudio.com/u/ToThrive)\
**Post date:** [April 23, 2025, 4:06am UTC](https://forum.wixstudio.com/t/exit-intent-lightbox-code/70400/6 "2025-04-23T04:06:36Z")

</div>

AH yes, I did come across that…will update it …thanks!
