-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryPasser.js
27 lines (25 loc) · 1005 Bytes
/
queryPasser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(function() {
if(location.search === ""){
return;
}
document.querySelectorAll('a[href]').forEach(function(ele){
var href = ele.getAttribute('href');
if (href !== 'undefined' || href.substr(0) != '' || href != null) {
switch(true){
case (href.substr(0, 1) == '#'):
ele.setAttribute('href', location.search + href);
break;
case (href.indexOf('#') > 0):
href = href.split('#');
ele.setAttribute('href', href[0] + location.search + '#' + href[1]);
break;
case (href.indexOf('?') > 0 || href.indexOf('&') > 0):
ele.setAttribute('href', href + '&' + location.search.substring(1));
break;
default:
ele.setAttribute('href', href + location.search);
break;
}
}
});
})();