471,066 Members | 1,200 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

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

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
3 1087
"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
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
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.

Similar topics

1 post views Thread by David Chan | last post: by
3 posts views Thread by Rennie deGraaf | last post: by
35 posts views Thread by Boobie | last post: by
16 posts views Thread by Joel Finkel | last post: by
21 posts views Thread by Johan Tibell | last post: by
8 posts views Thread by Frank | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.