简体   繁体   中英

Prevent JavaScript page jumping

I have a Magento 2 site and when a tab or accordion link is clicked the page scrolls to top of content. How can I prevent this?

The filter tabs on the left (desktop only) http://designacake.co.uk/bakeware

The accordion at the bottom of the product section: http://designacake.co.uk/katy-sue-designs-mould-creative-cake-system-easy-fabric-puff

Thank you.

That DOM element likely has an onClick event which is setting the scroll height of the page. See https://www.w3schools.com/jsref/met_win_scrollto.asp and https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick for more information.

You will need to read through the source code of your website and find out where the onClick event was bound and try to disable the scrolling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM