Skip to main content

Posts

Showing posts from February, 2015

anchor tag work on double click javascript

DOUBLE CLICK WORK ON ANCHOR TAG (HTML) HTML <html> <head> <script>   var clicked=false;;       var el = document.getElementById('link');            el.onclick = function(e) {         if(!clicked) {         clicked = true;         timer = setTimeout(function() { clicked = false}, 500);           e.preventDefault();         }                 } </script> </head> <body> <a id="link" href="http://www.google.com">sd</a> </body> </html>

ANCHOR REDIRECTION USING JAVASCRIPT

Redirect anchor tag using java script $ ( 'a' ). click ( function () { var href = $ ( this ). attr ( 'href' ); if (! $ ( this ). data ( 'timer' )) { $ ( this ). data ( 'timer' , setTimeout ( function () { window . location = href ; }, 500 )); } return false ; //if upper code false then defaut redirection will run }); $ ( 'a' ). dblclick ( function () { clearTimeout ( $ ( this ). data ( 'timer' )); $ ( this ). data ( 'timer' , null ); // you can do something else here return false ; });