In Chrome Devtools, you can break javascript on changing a DOM element's attributes, or on subtree modifications of an element.
I'm working on some legacy code that has some javascript that scrolls to the top of the page under certain situations, and I want to find the JS that does this.
Is there a way, in Devtools, so break on scroll events?
It could be jQuery or Prototype.js or event base JS that does it, and I've searched the codebase for .scrollTop or .animate, and I've found plenty of those, but none that are causing my issue.
Simple steps to scroll down in a web browser To scroll down in a web browser simply press your keyboard spacebar. To scroll up press shift + spacebar while viewing a website. You can also place your cursor over the website content you are viewing and press your up/down keyboard arrow keys.
The Window.scroll() method scrolls the window to a particular place in the document. window.scroll(x-coord, y-coord) window.scroll(options) x-coord is the pixel along the horizontal axis of the document that you want displayed in the upper left. y-coord is the pixel along the vertical axis of the document that you want displayed in the upper left.
HTML DOM Window Scroll () Method Last Updated : 29 Jul, 2020 The Window scroll () method scrolls the window to a particular place in the document. This method is different form scrollTo () method as it takes different parameters like scrolling behavior, etc using ScrolltoOptions Dictionary.
You can use the following keyboard shortcuts to control the Autoscroll bookmarklet while scrolling is in progress: 0–9 — Sets scroll speed (higher is faster) – (minus) — Decreases scroll speed = (equals) — Increases scroll speed
I have no additional idea about actually breaking than the ones presented.
But i suspect it is not scrolling that causes the issue, but a '#' in the html.
<a href="#" onclick="return false;">x</a>
is a very common pattern. when you forget (or something prevents) the "return false", the # (empty anchor) will be navigated to, which causes a scroll to top.
Check if the url has a # at the end after clicking!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With