Skip to content

Instantly share code, notes, and snippets.

@robertbanh
Created March 27, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertbanh/9c0b812652bcf79a506c851f9e65a084 to your computer and use it in GitHub Desktop.
Save robertbanh/9c0b812652bcf79a506c851f9e65a084 to your computer and use it in GitHub Desktop.
Add GET fields from current URL to all hyperlinks on page
<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