function getCookie(name) { var matches = document.cookie.match(new RegExp( "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" )); return matches ? decodeURIComponent(matches[1]) : undefined; } var ss = getCookie('devicePixelRatio'); if(ss !== undefined){ window.addEventListener("load", function(event) { var elements = document.getElementsByClassName("cactus-text-style"); console.log(elements); for (var i = 0, len = elements.length; i < len; i++) { var elLink = elements[i].getAttribute('data-link'); var elText = elements[i].getAttribute('data-text'); var elClasses = elements[i].getAttribute('data-classes'); var redirectLink = document.createElement('a'); redirectLink.href= elLink; redirectLink.target = '_blank'; redirectLink.rel = 'nofollow'; if(null !== elClasses ){ redirectLink.className += " "+elClasses; } redirectLink.innerHTML = elText; elements[i].appendChild(redirectLink); } }); }