-1

I want to append additional key value to the querystring for all request going to the web server i.e. Direct href, Ajax get post is there any generic way of implementing this? Kind of client side handler?

If this is not possible then is it possible to sent extra request header through a central code?

3

1 Answer 1

0
window.addEventListener("click", function(e) {
    var href = e.target.getAttribute("href");
    if(href) {
        location.href = href + "?q=stackoverflow";
        e.preventDefault();
    }
});​

Add parameters to an URL from a <a href> just clicked

3
  • How this can be made more foolproof by identifying if this is a redirection not just a expand collapse icon +/- click or inside page event? May 28, 2015 at 15:41
  • You can add a class to it and inside click listener check if that link has the class you have added don't append params May 28, 2015 at 15:50
  • Certainly that's one of the solution however my application is prd so I am thinking other way round to tackle this..e.g. By trying to find if unload event is in the event chain, certain jquery attribute etc.. May 28, 2015 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.