How To Get Variable's Value From Url And Pass To All The Links On The Whole Site?
I am trying to get a variable from a URL, for example if the users can link to this page: www.example.com?var1=blabla&var2=blabla and there are many links on this site www.exa
Solution 1:
Your code looks good to me. And from your question it appears that your problems lie outside this.
My question is: I can only make all the links on the same page append those 2 variable. If the users go to another page, it won't do the same thing, because there is no script on it... but I can't add same script on every pages...
If you can't run your script on every page then you can't modify the url's. You will need to do it server side. If you can't do it server side then you are out of luck.
And another question, I want to clear the things after question mark and append the new ones.. is that possible to do that?
Yes, that is certainly possible. To strip the querystring use the following code.
var strippedHREF = window.location.href.substring(0, window.location.href.indexOf('?'));
Post a Comment for "How To Get Variable's Value From Url And Pass To All The Links On The Whole Site?"