Forum Moderators: open
I have this script but I couldn't get it to work:
--------------------------------------
<html>
<head>
<title>Click Bomber Defense</title>
<script language="JavaScript">
var clickCount = readCookie();
if ( clickCount == null ){
clickCount = 0;
}
function trackclick() {
clickCount = parseInt(clickCount)+1;
setCookie( clickCount, 2 );
return true;
}
function setCookie( cookieValue, nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null ¦¦ nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = "clicktrack="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}
function readCookie() {
var nameEQ = "clicktrack=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0){
return c.substring(nameEQ.length,c.length);
}
}
return null;
}
</script>
</head>
<body>
<div id="banners" onclick="trackclick();">
<script language="JavaScript">
if ( clickCount > 2 ){
document.write('
<a href="http://example.net">
<img src="http://example.net/click-bomb.jpg" />
</a>
');
}else{
document.write('
ADSENSE Code Here
');
}
</script>
</div>
</body>
</html>
---------------------------------------
It doesn't seem to work however. I'm not very good at Javascript so perhaps guys can help me. Also, I am aware the cookies can be cleared which is a flaw in the method but you have to be determined to click bomb, 2 click at a time.
Is there anything wrong with the code?
For example, the user can click any ads, twice on the site and get linked to that ad, before an alternate image appears.
The user will see ads when the cookies are cleared.
Google has a guilty until proven innocent policy. It's far easier to prevent invalid clicks than it is to go through the hassle of sending in data.
Can anyone help me out?