Простейший clickunder
При клике в любое место на странице перекидывает на яндекс, делает это один раз в сутки (инфа в куках).
<!doctype html> <html> <body> <a href="http://google.com">click</a> </body> <script> document.onmouseup = function(){ if (getCookie('bdclk') == undefined) { setCookie('bdclk', 1, '/', 24*3600); window.open('http://www.ya.ru', '_blank'); return true; } return false; }; function getCookie(name) { if (/\W/.test(name)) return undefined; var matches = document.cookie.match(new RegExp("(?:^|; )" + name + "=([^;]*)")); return matches ? decodeURIComponent(matches[1]) : undefined; } function setCookie(name, value, path, expires) { var date = new Date( new Date().getTime() + expires * 1000 ); document.cookie = name + '=' + value + '; path=' + '/' +'; expires=' + date.toUTCString(); return true; } </script> </html>
5 ноября 2014, 17:49