# Scroll to top when lightbox is closed

**URL:** <https://forum.wixstudio.com/t/scroll-to-top-when-lightbox-is-closed/39202>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [July 2, 2022, 4:39pm UTC](https://forum.wixstudio.com/t/scroll-to-top-when-lightbox-is-closed/39202 "2022-07-02T16:39:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenn](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jenn](https://forum.wixstudio.com/u/jenn)\
**Post date:** [July 2, 2022, 4:39pm UTC](https://forum.wixstudio.com/t/scroll-to-top-when-lightbox-is-closed/39202/1 "2022-07-02T16:39:17Z")

</div>

I have four links at the bottom of a page to different lightboxes. When you open one, and then close it, the page scrolls to the top and I would like it to stay at the bottom. Any idea how to achieve this? Thanks!

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [July 3, 2022, 6:58pm UTC](https://forum.wixstudio.com/t/scroll-to-top-when-lightbox-is-closed/39202/2 "2022-07-03T18:58:03Z")

</div>

In order to do it, you’ll have to open and close the lightbox with code only.  
remove the auto-close(the X or the overlay - via the lightbox settings).

And do something like:

```javascript
//Parent page
import wixWindow from 'wix-window';
$w.onReady(() => {
    $w('#bottonLink1').onClick(event => {
        let y = event.clientY - event.offsetY;
        wixWindow.openLightbox('Lightbox_Name')
        .finally(() => {
        wixWindow.scrollTo(0, y, {scrollAnimation:false});
        })
    })
})

```

```javascript
//Lightbox
import wixWindow from 'wix-window';
$w.onReady(() => {
$w('#closeButton').onClick(wixWindow.lightbox.close);
})

```

---

<div class="post-metadata">

**Author:** ![jenn](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jenn](https://forum.wixstudio.com/u/jenn)\
**Post date:** [July 3, 2022, 11:38pm UTC](https://forum.wixstudio.com/t/scroll-to-top-when-lightbox-is-closed/39202/3 "2022-07-03T23:38:43Z")

</div>

Great, thanks so much!

---

<div class="post-metadata">

**Author:** ![uklee92](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uklee92](https://forum.wixstudio.com/u/uklee92)\
**Post date:** [January 26, 2023, 4:12pm UTC](https://forum.wixstudio.com/t/scroll-to-top-when-lightbox-is-closed/39202/4 "2023-01-26T16:12:55Z")

</div>

Hello J.D,

what would be the code If I want the page to be stay the same when the lightbox is closed?

I don’t want the page to be scrolled up with scrolled down, when the lightbox is closed, it just close, without scrolling to anywhere.
