So I was trying to accomplish something like this
how to get variable's value from URL and pass to all the links on the whole site?
But the problem I ran into is when you just visiting the home page or any page without the variable value it makes all links on the page to look like this:
http://www.website.com/page1/?http://www.website.com/
So it adds the whole url as a variable value, and what I need to accomplish is when you visit page
www.example.com/page1.php?var1=blabla
it keeps that variable value throughout the website, but if you just visit www.example.com/page1.php you won't see any variable value.
what do I need to change in this code to get rid of this problem
<script type="text/javascript">
$(document).ready(function() {
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1);
var links = $('a');
links.each(function(){
var curLink=$(this);
var href = curLink.attr('href');
var newhref = href +'?'+ hashes;
curLink.attr('href',newhref);
});
});
</script>
Thank you for any help