Javascript Click Counter

brian505

New Member
I have this javascript:
Code:
<script type="text/javascript">
var clicks = 0;
function linkClick(){
    document.getElementById('clicked').value = ++clicks;
}

document.write('<a href="#" onclick="linkClick()">Click Me!</a>');
</script>


The above counts clicks.

Code:
You have clicked the link <input id="clicked" size="3" onfocus="this.blur();" value="0" > times.

The above displays the click count.

Can anyone show me how to make the page redirect to a specified URL after the 10th click?
 

PixelPusher

Super Moderator
Staff member
Need to declare a variable that holds the count number.
Then have the click function add one each time.
Then have a case statement saying if click number equals 10 then do this [redirect].
 
Top