By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,527 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,527 IT Pros & Developers. It's quick & easy.

Need a logical flow of javascript calls to execute like I want them... can't figure it out.

P: n/a
Ok, this may seem like a really stupid code help request, but i've got
this funny little longstanding Javascript bug going on with Netscape
that I've finally nailed... but only if I can get these calls to run
like I want them... but I don't know how to parse this out.

What I need is for a function call to execute only once on a
onkeydown, with the other calls executed with each keydown...

So logically it would flow something like this:

onkeydown="runonce_onkeydown();run_each_keydownA() ;run_each_keydownA();"

Anyone can figure this out?
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Matthew" <ma******@yahoo.com> wrote in message
news:19**************************@posting.google.c om...
<snip>
What I need is for a function call to execute only once
on a onkeydown, with the other calls executed with each
keydown...

So logically it would flow something like this:

on
keydown="runonce_onkeydown();run_each_keydownA(); run_each_keydownA();"

^
Should that be a B?

function initialOnKeyDown(element){
runonce_onkeydown();
afterInitialOnKeyDown();
element.onkeydown = afterInitialOnKeyDown;
}

function afterInitialOnKeyDown(){
run_each_keydownA();
run_each_keydownB();
}

onkeydown="initialOnKeyDown(this);"

Richard.
Jul 20 '05 #2

P: n/a
Matthew wrote:
Ok, this may seem like a really stupid code help request, but i've got
this funny little longstanding Javascript bug going on with Netscape
that I've finally nailed... but only if I can get these calls to run
like I want them... but I don't know how to parse this out.

What I need is for a function call to execute only once on a
onkeydown, with the other calls executed with each keydown...

So logically it would flow something like this:

onkeydown="runonce_onkeydown();run_each_keydownA() ;run_each_keydownA();"

Anyone can figure this out?


Another less elegant, but equally useful solution:

var ran_once = false;

function keyDownAction(element){
if(!ran_once) {
runonce_onkeydown();
ran_once = true;
}
run_each_keydownA();
run_each_keydownB();
}

Jul 20 '05 #3

P: n/a
Ah, that's great. Cheers!

MMc

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message news:<c0*******************@news.demon.co.uk>...
"Matthew" <ma******@yahoo.com> wrote in message
news:19**************************@posting.google.c om...
<snip>
What I need is for a function call to execute only once
on a onkeydown, with the other calls executed with each
keydown...

So logically it would flow something like this:

on
keydown="runonce_onkeydown();run_each_keydownA(); run_each_keydownA();"

^
Should that be a B?

function initialOnKeyDown(element){
runonce_onkeydown();
afterInitialOnKeyDown();
element.onkeydown = afterInitialOnKeyDown;
}

function afterInitialOnKeyDown(){
run_each_keydownA();
run_each_keydownB();
}

onkeydown="initialOnKeyDown(this);"

Richard.

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.