Share
  • Facebookでシェアする

CLOSE

window.addEventListener('load',function() { const links = document.getElementsByTagName('a'); const listener = function(e) { const xdomain = ['jp.toto.com', 'order.toto.jp']; if (typeof URLSearchParams === 'undefined') return; if (!e.target.href) return; if (!xdomain.some(function(value) { return e.target.hostname.indexOf(value) !== -1})) return ; const params = new URLSearchParams((new URL(window.location)).search.slice(1)); const yclid = params.get('yclid'); if (yclid) { let lurl = new URL(e.target.href); let lparam = new URLSearchParams(lurl.search.slice(1)); lparam.set('yclid', yclid); lurl.search = lparam.toString(); e.target.href = lurl.toString(); } }; for (let i = 0; i< links.length; i++) links[i].addEventListener('click', listener); });