I am trying to pass url parameters through to the next pages by appending them to all the links on the page. The code I have works fine for this purpose.
I am encountering trouble when having anchor links on the page, as it puts the parameters after the URL and after the anchor as well, preventing the link from going to the anchor point.
Ex. website.com/?param1=test/#anchor?param1=test
Here is my code:
<script type="text/javascript">
jQuery(document).ready( function($) {
var params = window.location.search.replace(/\+/g,'%20');
var button = $('a[href]').each( function(i) {
this.href = this.href + params;
});
});
</script>
Any help would be greatly appreciated!