Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <style>
    #target {
      background-color:green;
      height: 100px;
    }
  </style>
  <h1>Vibration with long-press</h1>
  <div id="target">
    Long-press here (without any prior activation like tap or click) should cause
    a long vibration which is different from system vibration.
  </div>
  <div id="log">
  </div>
  <script>
    function log(msg) {
      document.getElementById("log").innerHTML += msg;
    }
    document.getElementById("target").addEventListener("contextmenu", e => {
      let ret = window.navigator.vibrate(200,200,200,200,200,200,200);
      log(e.type + " " + ret + "<br>");
      e.preventDefault();
    });
  </script>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
mustaqpro
0viewers