-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?

1 Answers1

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

Community
  • 1
  • 1
Pardeep Dhingra
  • 3,746
  • 6
  • 27
  • 52
  • 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? – user4903642 May 28 '15 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 – Pardeep Dhingra May 28 '15 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.. – user4903642 May 28 '15 at 15:58