Amresh Chandra Jha

I am always here to help u guys........

Thursday, 11 August 2022


<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<style>

      

       body {

-webkit-touch-callout: none;

-webkit-user-select: none;

-khtml-user-select: none;

-moz-user-select: none;

-ms-user-select: none;

user-select: none;

}

    </style>

</head>


<body>

    <!-- <button href="" title="">Long press</button> -->

   <button id="ping">Press</button>

    <script>

    var onlongtouch; 

    var timer;

    var touchduration = 800; //length of time we want the user to touch before we do something


    function touchstart(e) {

        e.preventDefault();

        if (!timer) {

            timer = setTimeout(onlongtouch, touchduration);

        }

    }


    function touchend() {

        //stops short touches from firing the event

        if (timer) {

            clearTimeout(timer);

            timer = null;

        }

    }


    onlongtouch = function() { 

        timer = null; 

        alert("hello---------")

    };


   document.getElementById("ping").addEventListener('touchstart',touchstart);

document.getElementById("ping").addEventListener('touchend',touchend);

    </script>

</body>


</html>