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

M

Matthew

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?
 
R

Richard Cornford

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.
 
B

Brian Genisio

Matthew said:
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();
}
 
M

Matthew

Ah, that's great. Cheers!

MMc

Richard Cornford said:
^
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top