title: count and redirect url in javascript like as whatsapp locker
body: <p>Please help me to solve this logic: When a user in mobile device and after clicking on button then whatsapp is open with my site URL then user share this URL with his friends. I want to perform this action 2 times or more after action completed user is redirected to another website.</p>
  
  <pre><code>&lt;!DOCTYPE&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Share Content on WhatsApp Using jQuery Demo - &lt;MyCodingTricks/&gt;&lt;/title&gt;
      &lt;style&gt;
      body{background-color:#49C34F}
      .mct_whatsapp_btn {
          background: #11A518;
          color: white;
          font-size: 16px;
          padding: 6px 9px 6px 28px;
          border-radius: 2px;
          position: relative;
          transition: ease-in all 0.3s;
          moz-transition: ease-in all 0.3s;
          -o-transition:ease-in all 0.3s;
          -webkit-transition: ease-in all 0.3s;
          text-decoration: none;
          box-shadow: inset 3px 1px 1px rgba(17, 165, 24, 0.25);
          border: 1px solid #028408;
      }
  
      .mct_whatsapp_btn:before {
          content: '';
          background: url(http://mycodingtricks.com/demo/javascript/how-to-share-content-on-whatsapp-using-jquery/whatsapp.png);
          position:absolute;
          top: 6px;
          left: 7px;
          width:16px;
          transition: ease-in all 0.3s;
          moz-transition: ease-in all 0.3s;
          -o-transition:ease-in all 0.3s;
          -webkit-transition: ease-in all 0.3s;
          height:16px;
      }
  
      .mct_whatsapp_btn:hover {
          background: #028408;
          text-decoration: none;
          color:white;
          border: 1px solid #11A518;
          box-shadow: inset 3px 1px 1px rgba(2, 132, 8, 0.25);
      }
  
      .mct_whatsapp_btn:hover:before {
          transform: rotate(360deg);
      }
      &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div class="container"&gt;
       &lt;div class="row"&gt;
        &lt;div class="col-md-12 well"&gt;
  
          &lt;a href="#" data-text="2 Ways to Count Facebook Likes, Shares and Comments using PHP" data-link="http://mycodingtricks.com/php/2-ways-to-count-facebook-likes-shares-and-comments-using-php/" class="mct_whatsapp_btn"&gt;Share&lt;/a&gt;
  
         &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
      var click=0;
      $(document).ready(function() {
  
          $(document).on("click", '.mct_whatsapp_btn', function() {
           click += 1;
           alert("you clicks"+click+"times" );
          if (click == 2) {
          window.location.href = www.google.com;
          }
          else{
               if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
                  var text = $(this).attr("data-text");
                  var url = $(this).attr("data-link");
                  var message = encodeURIComponent(text) + " - " + encodeURIComponent(url);
                  var whatsapp_url = "whatsapp://send?text=" + message;
                  window.location.href = whatsapp_url;
              } else {
                  alert("Please use an Mobile Device to Share this Article");
              }
          }
  
  
          });
      });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>