javascript - Append bannercode from a webpage -


i've got problem i'm having trying append bannercode end of url. customer journey follows:

  • person receives email contains link site (site1), url contain banner code e.g. www.site1.com?banner=helloworld
  • once person on site, there 2 buttons take customer second site:

 

$(document).ready( function () {     var banner = string($.query.get('banner'));     if(banner){         href = $('a[href^="https://"]').attr("href") + "?banner=" + banner;             $('a[href^="https://"]').attr("href", href);     } }); 

basically happens is, piece of code have makes both buttons go same url example button 1. how can script not change url buttons? in advance.

do understand right: want add banner part every link, keep original part unchanged?

$(document).ready(function(){ var banner=string($.query.get('banner')); if(banner){     $('a[href^="https://"]').attr('href',function(){         return this+'?banner='+banner;     }); } }); 

or in shorter:

$(document).ready(function(){     (banner=$.query.get('banner'))?$('[href^=https]').attr('href',function(){             return this+'?banner='+banner}):null; }) 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -