Skip to content

The Unified and Autonomous Development Platform

fix issue #104: Issue comment anchor does not work as expected in Firefox

Robin Shen169396678d05
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/base.js b/server-core/src/main/java/io/onedev/server/web/page/base/base.js
index 99d2021f9b..81d09ae414 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/base/base.js
+++ b/server-core/src/main/java/io/onedev/server/web/page/base/base.js
@@ -731,8 +731,11 @@ onedev.server = {
if (location.hash && !onedev.server.viewState.getFromHistory()) {
// Scroll anchors into view (for instance the markdown headline)
- var element = document.getElementsByName(decodeURIComponent(location.hash.slice(1)))[0];
- if (element)
+ var nameOrId = decodeURIComponent(location.hash.slice(1));
+ var element = document.getElementById(nameOrId);
+ if (!element)
+ element = document.getElementsByName(nameOrId)[0];
+ if (element)
element.scrollIntoView();
}
}