Re: Performing Double Click and Drag & Drop using Javascript

Wednesday, November 7, 2012

Below is a complete cross-browser compliant page that demonstrates the proper use of setTimeout method.
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.

<title>setTimeout & Double Click Demo</title>
// 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)
    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;
    if (ClickState == 1)
    ClickState = 2;   

<button onclick='OnClick()'>Click Me</button>
<div id='SH'></div>

On Sunday, November 4, 2012 11:40:30 PM UTC-5, Nathan Mynarcik wrote:
This should get ya started:

On Sun, Nov 4, 2012 at 9:31 PM, SACHIN V <> wrote:
Hi Nathan,

I don't know how to use it.. Can you please be more elaborate?



Post a Comment

Note: Only a member of this blog may post a comment.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii