From a4f10167d94f1788a5ea9966b1d7cb9687000e89 Mon Sep 17 00:00:00 2001 From: Karl Kleinpaste Date: Tue, 28 Jul 2026 10:52:05 -0400 Subject: [PATCH 1/2] replace old hash-based anchor setting with modern scrollIntoView(). --- src/gtk/utilities.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gtk/utilities.c b/src/gtk/utilities.c index 87a263780..ab46d4842 100644 --- a/src/gtk/utilities.c +++ b/src/gtk/utilities.c @@ -1320,11 +1320,19 @@ HtmlOutput(char *text, GtkWidget *gtkText, MOD_FONT *mf, char *anchor) for (q = safe_anchor; (q = strstr(q, "" - " window.onload = function () { window.location.hash = \"%s\"; }" - " ", - safe_anchor); + + buf = g_strdup_printf("", + safe_anchor, safe_anchor); g_free(safe_anchor); XIPHOS_HTML_WRITE(html, buf, strlen(buf)); g_free(buf); From 7132242724833fbd5d56351111171ec2aaa64f95 Mon Sep 17 00:00:00 2001 From: Karl Kleinpaste Date: Tue, 28 Jul 2026 11:43:30 -0400 Subject: [PATCH 2/2] differentiate old-but-working location.hash for modern webkit2 vs machinations for windows webkit1. --- src/gtk/utilities.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/gtk/utilities.c b/src/gtk/utilities.c index ab46d4842..b822bf618 100644 --- a/src/gtk/utilities.c +++ b/src/gtk/utilities.c @@ -1320,19 +1320,34 @@ HtmlOutput(char *text, GtkWidget *gtkText, MOD_FONT *mf, char *anchor) for (q = safe_anchor; (q = strstr(q, "" "window.onload = function() {" " setTimeout(function() {" - " var el = document.getElementsByName('%s')[0] || " - " document.getElementById('%s');" + " var name = '%s';" + " var el = document.getElementsByName(name)[0] || document.getElementById(name);" " if (el) {" - " el.scrollIntoView(true);" + " var y = 0;" + " var node = el;" + " while (node) {" + " y += node.offsetTop;" + " node = node.offsetParent;" + " }" + " window.scrollTo(0, y);" + " document.documentElement.scrollTop = y;" + " document.body.scrollTop = y;" " }" - " }, 0);" + " }, 10);" "};" - "", - safe_anchor, safe_anchor); + "", safe_anchor); +#else + // the older location.hash method still works most reliably in modern webkit2. + buf = g_strdup_printf("", + safe_anchor); +#endif g_free(safe_anchor); XIPHOS_HTML_WRITE(html, buf, strlen(buf)); g_free(buf);