improve:footnote url(#fragment) navigation

This commit is contained in:
xiaoyifang 2022-01-09 11:54:14 +08:00
parent 3f11826918
commit 29bd94b8a7

View file

@ -7,13 +7,28 @@ $(function() {
}
var newLink;
if (link.startsWith("#")) {
newLink = window.location.href + link;
} else {
var href = window.location.href;
if (link.startsWith("#")) {
//the href may contain # fragment already.remove them before append the new #fragment
var index = href.indexOf("#");
if(index>-1)
{
newLink = href.substring(0, index) + link;
}
else{
newLink= href+link;
}
} else {
var index = href.indexOf("?");
if(index>-1)
{
newLink = href.substring(0, index) + "?word=" + link;
}
else{
newLink=href+"?word=" + link;
}
}
$(this).attr("href", newLink);
});