From: Chris Fulljames Date: Tue, 4 Mar 2025 00:58:06 +0000 (-0500) Subject: Scroll to top when loading new page X-Git-Url: https://littlesong.place/gitweb/gitweb.cgi?a=commitdiff_plain;h=43011e4dd83f1875ec760961125c3aa3ed1e0709;p=littlesongplace.git Scroll to top when loading new page --- diff --git a/static/nav.js b/static/nav.js index 101e3e5..4926f83 100644 --- a/static/nav.js +++ b/static/nav.js @@ -72,9 +72,8 @@ async function handleAjaxResponse(response) { // Got an error; redirect to the error page window.location.href = response.url; } - // Update URL in browser window, minus request-type field + // Update URL in browser window var url = new URL(response.url); - url.searchParams.delete("request-type"); // Get page content from response var text = await response.text(); @@ -124,6 +123,9 @@ function updatePageState(data) { // Trigger event to signal new page has loaded var event = new Event("DOMContentLoaded"); document.dispatchEvent(event); + + // Scroll to top of page + window.scrollTo(0, 0); } async function checkForNewActivity() { diff --git a/todo.txt b/todo.txt index 4b6fc78..492a1db 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,3 @@ -- Scroll to top of new page - Add to playlist in background - Pinned profile playlists