It simulates the double click functionality via an onclick event attached to a BUTTON
element. Click once on the button and the psuedoOnClick()function is executed.
Click twice within a 200 millisecond window and psuedoOnDoubleClick() function is executed.
===== BEGIN HTML PAGE
<html>
<head>
<title>setTimeout & Double Click Demo</title>
<script>
// This page implements psuedo double click event via an element's onclick event.
var DBLTIME = 200; // Number of millisecs to wait after first onclick before firing
// psuedoOnClick()
// If second click happens before this time,
// psuedoOnDoubleClick() is called.
var Undef;
function Gid(id) {
return document.getElementById(id);
}
function Put(id,s) {
Gid(id).innerHTML = s;
}
var ClickState; // State variable used to count clicks.
function psuedoOnClick() {
Put("SH", "You single clicked.");
}
function psuedoOnDoubleClick() {
Put("SH", "You double clicked.");
}
// This function is called DBLTIME millisconds after
// OnClick() is executed.
function OnTimer() {
if (ClickState == 1)
psuedoOnClick();
ClickState = Undef;
}
function OnClick() {
if (ClickState == Undef) {
// The following line will call the OnTimer() function
// after DBLTIME milliseconds expire.
window.setTimeout("OnTimer()", DBLTIME);
ClickState = 1;
return;
}
if (ClickState == 1)
psuedoOnDoubleClick();
ClickState = 2;
}
</script>
</head>
<body>
<button onclick='OnClick()'>Click Me</button>
<div id='SH'></div>
</body>
</html>
====== END HTML PAGE
On Sunday, November 4, 2012 11:40:30 PM UTC-5, Nathan Mynarcik wrote:
This should get ya started: http://www.w3schools.--com/jsref/met_win_settimeout. asp
On Sun, Nov 4, 2012 at 9:31 PM, SACHIN V <mr.vs...@gmail.com> wrote:Hi Nathan,
I don't know how to use it.. Can you please be more elaborate?
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.