fix:relative url redirect

This commit is contained in:
yifang 2022-01-01 21:09:55 +08:00
parent aaea8d8e04
commit 47faab5a52

View file

@ -2,12 +2,18 @@
$(function() { $(function() {
$("a").click(function(event) { $("a").click(function(event) {
var link = $(this).attr("href"); var link = $(this).attr("href");
if (link.indexOf("://") < 0) { var newLink;
var newLink = window.location.href + "/" + link; if (link.startsWith("#")) {
$(this).attr("href", newLink); newLink = window.location.href + link;
} else {
var href = window.location.href;
var index = href.indexOf("?");
newLink = href.substring(0, index) + "?word=" + link;
} }
$(this).attr("href", newLink);
}); });
} }
); );