<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Long Mouse Press</title>
<script>
var longpress = false;
var counter = 0;
function showM(s)
{
document.getElementById("test").innerHTML = s+"<br>"+counter;
}
function MYonclick()
{
if (!longpress) {
counter += 1;
showM('Mouse Click'); // What to do if clicked
}
}
</script>
</head>
<body>
<div align="center">
<div id="test" style="width:300px; height:100px; border:thin #FF9900 solid; cursor:pointer; font-size:32px" title="Click me
or
Press and hold"
onclick="MYonclick()"
onmousedown="presstimer = setTimeout(function() {
longpress = true;
counter += 5; showM('Long Press'); // what to do!
}, 1000);"
onmouseup="setTimeout(function() {clearTimeout(presstimer); longpress = false;},100);">
</div>
</div>
</body>
</html>