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,10 +2,16 @@
$(function() {
$("a").click(function(event) {
var link = $(this).attr("href");
if (link.indexOf("://") < 0) {
var newLink = window.location.href + "/" + link;
$(this).attr("href", newLink);
var newLink;
if (link.startsWith("#")) {
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);
});
}