Created
March 27, 2018 18:30
-
-
Save robertbanh/9c0b812652bcf79a506c851f9e65a084 to your computer and use it in GitHub Desktop.
Add GET fields from current URL to all hyperlinks on page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('a').each(function() { | |
var href = $(this).attr('href'); | |
if (href !== undefined) { | |
if (href.indexOf('?') == -1) { | |
var url = document.URL; | |
var index = url.indexOf('?'); | |
if (index != -1) { | |
url = url.substring(index); | |
$(this).attr('href', href + url); | |
} | |
} | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment