I have this javascript: <script type="text/javascript"> var clicks = 0; function linkClick(){ document.getElementById('clicked').value = ++clicks; } document.write('<a href="#" onclick="linkClick()">Click Me!</a>'); </script> Code (markup): The above counts clicks. You have clicked the link <input id="clicked" size="3" onfocus="this.blur();" value="0" > times. Code (markup): The above displays the click count. Can anyone show me how to make the page redirect to a specified URL after the 10th click?
<script type="text/javascript"> var clicks = 0; function linkClick(){ document.getElementById('clicked').value = ++clicks; if (clicks === 10) { window.location = "http://www.google.com/"; } } document.write('<a href="#" onclick="linkClick()">Click Me!</a>'); </script> </head> Code (markup): You're welcome.