# Prevent page going back to top after clicking custom component modal

**URL:** <https://forum.builder.io/t/prevent-page-going-back-to-top-after-clicking-custom-component-modal/3751>\
**Category:** Technical Questions\
**Tags:** angular, custom-components\
**Created:** [June 21, 2023, 11:10pm UTC](https://forum.builder.io/t/prevent-page-going-back-to-top-after-clicking-custom-component-modal/3751 "2023-06-21T23:10:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedson](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@cedson](https://forum.builder.io/u/cedson)\
**Post date:** [June 21, 2023, 11:10pm UTC](https://forum.builder.io/t/prevent-page-going-back-to-top-after-clicking-custom-component-modal/3751/1 "2023-06-21T23:10:54Z")

</div>

**Builder content link**

> **[Builder.io: Drag & Drop Headless CMS](https://builder.io/content/5994551a358c4a449fffc209f0bd27c1/edit?activeDesignerTab=5)**
>
> Drag and drop with your components, right within your existing site or app. Build and optimize digital experiences for any tech stack, visually..

**Builder public api key**  
22d7e777310243139ed9f12ba85d84f0

**What are you trying to accomplish**  
I’m trying to prevent the page refreshing and going back to the top after clicking one of our custom button components. These custom buttons open a custom model that our frontend engineers have built. After I close the button, I don’t want the page to load at the top, but at the same spot on the page where I clicked the button. I’ve tried using event.preventdefault() javascript code as well. Please let me know if you have any ideas.

**Screenshots or video link**  
_Screenshots of your issue, or even better a link to a video of what is happening or what you are trying to accomplish. We love using loom for that sort of thing_

**Code stack you are integrating Builder with**  
angular, chrome

---

<div class="post-metadata">

**Author:** ![nicke920](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@nicke920](https://forum.builder.io/u/nicke920)\
**Post date:** [June 21, 2023, 11:57pm UTC](https://forum.builder.io/t/prevent-page-going-back-to-top-after-clicking-custom-component-modal/3751/2 "2023-06-21T23:57:49Z")

</div>

Hi there,

Thanks for reaching out!

If there is a reload on the page, unless you have attached [an anchor link](https://forum.builder.io/t/how-to-add-anchor-links-to-a-builder-page/188) to an element, and the id matches in the url.

 ![Screen Shot 2023-06-21 at 4.54.59 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/e/ebb9ff5426a48973604b898beb675b85ff73ee82.png)

Alternatively, you could explore more JS solutions with your developers that can save the scroll position in local storage, and then call it when the page reloads. I’ve attached a few Stack Overflow links that will help get you and your engineers started:

- [javascript - Refresh Page and Keep Scroll Position - Stack Overflow](https://stackoverflow.com/questions/17642872/refresh-page-and-keep-scroll-position)
- [jquery - Retain scrollbar position even after reloading using javascript - Stack Overflow](https://stackoverflow.com/questions/34261365/retain-scrollbar-position-even-after-reloading-using-javascript)
