Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hey Guys,
I am trying to implement a customized progress bar to one of my shopify pages and I need Javascript to implement it. Unfortunately my script is not working for shopify (even though it works on a different website)
I broke it down in the easiest way, only containing the not functioning parts:
HTML:
...
<div id="output"></div>
...
JS
var bodyy = document.querySelector("body");
document.addEventListener("scroll", () => {
output.textContent = bodyy.scrollTop;});
What's supposed to happen is that the output div changes depending on the scrolling position. But it returns 0 no matter what (the page is long enough to scroll and overflow is set to scroll)
Is anyone able to figure out why it doesn't recognize the scrolling position?
Thank you in advance!
I think it should help.
document.addEventListener("scroll", () => {
output.textContent = document.documentElement.scrollTop;});
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025