faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 7 people (71%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

I am calling a function on clicking certein image, which take half minit to execute. If i click twice the function should not be executed second time.

Apr 4th, 2008 20:56
ha mo, Juergen Thelen, kishor hanchate,


Use a running flag, indicating that the function is already running:
--- snip ---
var WhatEverRunning = false;
function WhatEver()
{
  if (!WhatEverRunning)
  {
    WhatEverRunning = true;
    // ..
    // your code doing what you want
    // ..
    WhatEverRunning = false;
  }
}
--- snap ---
Hth, Juergen
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com