Skip to content

Instantly share code, notes, and snippets.

@atwellpub
Last active September 29, 2015 20:21
Show Gist options
  • Save atwellpub/867aea28613244ccfbba to your computer and use it in GitHub Desktop.
Save atwellpub/867aea28613244ccfbba to your computer and use it in GitHub Desktop.
<script type='text/javascript'>
function getQueryArgs()
{
var query = window.location.search.substring(1);
var vars = query.split('&');
var params = {}
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
var key = decodeURIComponent(pair[0]);
var val = decodeURIComponent(pair[1].replace(/[+]/g,'%20'));
params[key] = val;
}
return params;
};
function updateLinks()
{
args = getQueryArgs();
var query_str = '';
for(var key in args)
query_str += key+'='+encodeURIComponent(args[key])+'&';
query_str = query_str.substr(0,query_str.length -1);
var nodes = document.getElementsByClassName('kform_presellLink');
var len = nodes.length;
if(len > 0)
{
for(var i in nodes)
{
var node = nodes[i];
var href = node.href;
if(href.indexOf('?') > -1)
href += "&"+query_str;
else
href += "?"+query_str;
node.href = href;
}
}
}
window.addEventListener('load',function()
{
updateLinks();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment