Shopify themes, liquid, logos, and UX
Anyone knows how to return to the same scroll position in dawn theme? I saw a fix for turbo theme which didn't apply for dawn.
Hi @oudelegance
Add this script to your theme.liquid file or base.js:
window.addEventListener("beforeunload", () => {
sessionStorage.setItem("scrollPosition", window.scrollY);
});
window.addEventListener("load", () => {
const scrollPosition = sessionStorage.getItem("scrollPosition");
if (scrollPosition) {
window.scrollTo(0, scrollPosition);
}
});
How it works:
Hi @oudelegance I was facing the same issue, and the code shared by @kirillatwally worked perfectly for me. You should give it a try.
Thank you 😊😊😊😊😊😊😊😊😊
Hi @oudelegance
I hope you are well. You can follow our instructions below:
Step 1: Shopify admin > Online store > Edit code: https://prnt.sc/M4p-gua99Uf4
Step 2: Search for "theme.liquid" file: https://prnt.sc/b6xveIKe-Rh2
Step 3: Open the file search for </body> tag and add the following code above </body> tag.
<script>
window.addEventListener("beforeunload", () => {
sessionStorage.setItem("scrollPosition", window.scrollY);
});
window.addEventListener("load", () => {
const scrollPosition = sessionStorage.getItem("scrollPosition");
if (scrollPosition) {
window.scrollTo(0, scrollPosition);
}
});
</script>
Here is the code for Step 3:
Please let me know if it works. Thank you!
Best,
Daisy - Avada Support Team.
Hi, thank you for your response.
I couldn't search for </body> it doesn't exist like that in theme.liquid.
So I pasted it here (see screenshot). Now does it need to be indented. This did not work for me. By the way, I am having this issue on mobile phone. When you click on a product from one of the collections, then click back, it takes you to the top of the homepage, not where you clicked on the product in the first place.
Hi @oudelegance
From the screenshot you shared, could you please scroll down to the bottom to find </body tag?
Best,
Daisy - Avada Support Team.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025