Bootstrap Templates Bundle

Tuesday, January 15, 2013

Hit Counter

If any one wants to add a hit counter for specific link or key or button then add this below code
N.B: I recommend you to see my post  Download/Link Hit Counter for better result
Sample1 : 

<HTML>
 <HEAD>
  <TITLE> Clicker Counter Thingamajig </TITLE>
</head>
<body>
<script type="text/javascript">
var clicks = 0;
function linkClick(){
    document.getElementById('clicked').value = ++clicks;
}
document.write('<a href="http://downloads.wordpress.org/plugin/wp-click-
track.zip" onclick="linkClick()">Click Me!</a>');
</script>
You have clicked the link <input id="clicked" size="3" onfocus="this.blur();"
value="0" > times.
 </BODY>
</HTML>


Sample2: 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
     <input type='submit' value='like' onclick='' id='aa' />
         <p style='clear: left;'> <span>0</span> like this. </p>
         <script>
         $("#aa").click(function () {
                 var n = parseInt($("span").text(), 10);
                         var a=0;
                       
                         n = n + 1;
                       
             $("span").text( a = parseInt(a) + parseInt(n));
         });
     </script>
</body>
</html>

limitation: Restore with each page load

No comments:

Post a Comment

Wokiee React eCommerce Template