Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32144 > unrolled thread

onkeyup not working for me in FireFox 50.1.0

Started by"Mel Smith" <syntel@cox.net>
First post2017-01-08 15:51 -0700
Last post2017-01-09 19:09 +0100
Articles 7 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  onkeyup not working for me in FireFox 50.1.0 "Mel Smith" <syntel@cox.net> - 2017-01-08 15:51 -0700
    onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-09 00:30 +0100
      Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0) "Mel Smith" <syntel@cox.net> - 2017-01-08 21:51 -0700
        Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-09 09:44 +0100
          Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0) "Mel Smith" <syntel@cox.net> - 2017-01-09 10:26 -0700
            Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-09 19:19 +0100
        Re: onkeyup in Firefox Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-09 19:09 +0100

#32144 — onkeyup not working for me in FireFox 50.1.0

From"Mel Smith" <syntel@cox.net>
Date2017-01-08 15:51 -0700
Subjectonkeyup not working for me in FireFox 50.1.0
Message-ID<edfu3kFkfvbU1@mid.individual.net>
Hi All:

    My onkeyup clause in my <input> element below works correctly under 
Chrome 54.0.2840.99

    That is, when I receive a <return> character, I sense it, 'blur' the 
field, and then go thru the validation process by executing my validate() 
function. Tabbing also works correctly.

    However, when testing under Firefox 50.1.0, the onkeyup clause fails to 
execute my chkforret function.  Apparently, I need to pass the 'event' as 
argument to the chkforret function instead of 'this' ??

My essential question is then:

    Does onkeyup 'work' in Firefox ?

     If so, what changes should I make to get it to work for me in the code 
below so that Chrome and FF are both satisfied ?

Thank you.

-Mel Smith


*** my currect js code for inputting a 3-char text field ***
<input type="text"; onkeyup="chkforret(this);(gotret)?this.blur():false;" 
onblur="setBlurColor(this);validate(this);" id="ulotno" name="lotno" 
size="4" maxlength="3" value="">
*************


[toc] | [next] | [standalone]


#32146 — onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-01-09 00:30 +0100
Subjectonkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)
Message-ID<7279249.NyiUUSuA9g@PointedEars.de>
In reply to#32144
Mel Smith wrote:

>     My onkeyup clause in my <input> element below works correctly under
> Chrome 54.0.2840.99

For suitable values of “correct”.
 
>     That is, when I receive a <return> character, I sense it, 'blur' the
> field, and then go thru the validation process by executing my validate()
> function. Tabbing also works correctly.

Do not do this.
 
>     However, when testing under Firefox 50.1.0, the onkeyup clause fails
>     to
> execute my chkforret function.  Apparently, I need to pass the 'event' as
> argument to the chkforret function instead of 'this' ??

Not necessarily.
 
> My essential question is then:
> 
>     Does onkeyup 'work' in Firefox ?

Yes, of course.  RTFM.
 
>      If so, what changes should I make to get it to work for me in the
>      code below so that Chrome and FF are both satisfied ?

Start from scratch and consume more caffeine this time.

> <input type="text"; onkeyup="chkforret(this);(gotret)?this.blur():false;"

BAD.  Broken as designed.

You are calling a user-defined *function* from an event-handler attribute 
value to set a *global variable*, that you subsequently access in the event-
handler attribute value – seriously?

The blur() call appears to be nonsense: If the Return key was released, you 
remove the focus from the control – to where?  If the released key is the 
Tab key or the Shift+Tab combination, you do not need to remove the focus 
manually, and UX-improving counter-measures of browser vendors (particularly 
Mozilla.org) will cause the call to be ignored.  If the released key is 
neither the Return key nor the Tab key, the user cannot enter more than one 
character in one attempt in that field – seriously?

The “false” there does not mean anything to the user agent if you do not 
return it to the event handler.  And you would not want to do that either 
(UX).

> onblur="setBlurColor(this);validate(this);"

Why setBlurColor()?

This is an instance where you want to add event listeners dynamically 
instead (because not all of those events might bubble in all target 
implementations).  The least you want to do is to handle the events at a 
common ancestor instead (in case they do bubble).

> id="ulotno" name="lotno"

Are there multiple controls with the same name?  If no, make ID and name the 
same in this case (this name is a Valid ID even in HTML < 5).  Omit the ID 
unless you are using it explicitly.

Finally, the name is _Firefox_.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#32149 — Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)

From"Mel Smith" <syntel@cox.net>
Date2017-01-08 21:51 -0700
SubjectRe: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)
Message-ID<edgj5vFp050U1@mid.individual.net>
In reply to#32146
Thomas said (too much for me to digest tonite.)

But, I also tried my code with IE 11 and it worked correctly (or to my 
satisfaction) as did Chrome 54.0.2840.99

Also, I did quite a bit of google searching. Many others complained of 
"onkeyup" not executing a specific function with Firefox

Anyway, my text field of has a max length of 3 chars and will (later) be 
followed by several other fields. I wish each of this to be 'blurred' when a 
user tabs or <return>s.

Also, below is my current chkforret() function. I never get to the alert() 
with Firefox but I do with the others. I'll try Safari tomorrow

Another also: my logical vrbl 'gotret' is global and is set to false on 
entry to the validate() function. If a <return> is sensed, it is set to 
true.

I only want chkforret() set the 'gotret' vrbl -- nothing further.

***********************
function chkforret(el) {
// alert("in chkforret() now") ;
var e = event ;
if (e===null) e = window.event ;

if (e.keyCode=="13") {
   gotret = true ;
   return false ;
   }
gotret = false ;
return true ;
}
**********************


[toc] | [prev] | [next] | [standalone]


#32150 — Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-01-09 09:44 +0100
SubjectRe: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)
Message-ID<XnsA6F8632E65743eejj99@194.109.6.166>
In reply to#32149
"Mel Smith" <syntel@cox.net> wrote on 09 Jan 2017 in comp.lang.javascript:

> function chkforret(el) {

Where do you use this el ????

> // alert("in chkforret() now") ;

> var e = event ;
> if (e===null) e = window.event ;

Use instead:

var e = event || window.event ;

BUT perhaps you ment:

function chkforret(el) {
  el = el || window.event;
  ...

====

> if (e.keyCode=="13") {
>    gotret = true ;
>    return false ;
>    }
> gotret = false ;
> return true ;
>}

Use instead:

return ! (gotret = e.keyCode == 13);


Did you var gotret globally??
Do you use the return value?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#32151 — Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)

From"Mel Smith" <syntel@cox.net>
Date2017-01-09 10:26 -0700
SubjectRe: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)
Message-ID<edhve0F53soU1@mid.individual.net>
In reply to#32150
Evertjan said:

>> function chkforret(el) {
>
> Where do you use this el ????

    I did use 'el' in several previous iterations of testing, but do not do 
so now, and forgot to remove it. (Will do so  today)

    Also, checked out Safari Version 5.1.7 (7534.57.2) on my dev PC today, 
and it works 'correctly'.

    So that leaves FF as 'odd-man-out' for now. (I haven't got Opera on my 
system because it is not frequently used in North America, and even less 
frequently among my 613 potential clients.)

>
>> // alert("in chkforret() now") ;
>
>> var e = event ;
>> if (e===null) e = window.event ;
>
> Use instead:
>
> var e = event || window.event ;
>

        Yes, will change this.  Thanks !

> BUT perhaps you ment:
>
> function chkforret(el) {
>  el = el || window.event;
>  ...
>
> ====
>
>> if (e.keyCode=="13") {
>>    gotret = true ;
>>    return false ;
>>    }
>> gotret = false ;
>> return true ;
>>}
>
> Use instead:
>
> return ! (gotret = e.keyCode == 13);
>
    O.K., will use this too.  (but should I not use ""13"" instead ?

>
> Did you var gotret globally??

    YES

> Do you use the return value?
>
    I use the value of  'gotret' when returning to the 'onkeyup' clause to 
'blur'. Then, the onblur clause operates.

btw, thru my server software I read html templates, build, and send pages to 
clients, access and manipulate databases. I use the Harbour language for 
this (a Hi-C type of language). www.whosaway.com

Next, I will be scratching my head and trying to re-learn AJAX. Used it a 
few years ago successfully. Since then, I've lost a lot of what I knew, and 
what I knew was then incomplete, wrong and now certainly out-of-date.

    I am still bothered that 'onkeyup'  is invisible to FF, whereas the 
three others I tested work for me as Iexpected.

Thanks for all the constructive suggestions above !  Will ensure they are 
implemented as you detailed.

-Mel Smith

[toc] | [prev] | [next] | [standalone]


#32153 — Re: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-01-09 19:19 +0100
SubjectRe: onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)
Message-ID<XnsA6F8C496F75C1eejj99@194.109.6.166>
In reply to#32151
"Mel Smith" <syntel@cox.net> wrote on 09 Jan 2017 in comp.lang.javascript:

> Evertjan said:
> 
>>> function chkforret(el) {
>>
>> Where do you use this el ????
> 
>     I did use 'el' in several previous iterations of testing, but do not
>     do 
> so now, and forgot to remove it. (Will do so  today)
> 
>     Also, checked out Safari Version 5.1.7 (7534.57.2) on my dev PC
>     today, 
> and it works 'correctly'.
> 
>     So that leaves FF as 'odd-man-out' for now. (I haven't got Opera on
>     my 
> system because it is not frequently used in North America, and even less
> frequently among my 613 potential clients.)
> 
>>
>>> // alert("in chkforret() now") ;
>>
>>> var e = event ;
>>> if (e===null) e = window.event ;
>>
>> Use instead:
>>
>> var e = event || window.event ;
>>
> 
>         Yes, will change this.  Thanks !
> 
>> BUT perhaps you ment:
>>
>> function chkforret(el) {
>>  el = el || window.event;
>>  ...
>>
>> ====
>>
>>> if (e.keyCode=="13") {
>>>    gotret = true ;
>>>    return false ;
>>>    }
>>> gotret = false ;
>>> return true ;
>>>}
>>
>> Use instead:
>>
>> return ! (gotret = e.keyCode == 13);
>>
>     O.K., will use this too.  (but should I not use ""13"" instead ?

Why? 
Does e.keyCode return a string?
Doesn't == do an automatic conversion,
while === is more strict?


>> Did you var gotret globally??
> 
>     YES
> 
>> Do you use the return value?
>>
>     I use the value of  'gotret' when returning to the 'onkeyup' clause
>     to 'blur'. Then, the onblur clause operates.

So your answer is "no"?

> btw, thru my server software I read html templates, build, and send
> pages to clients, access and manipulate databases. I use the Harbour
> language for this (a Hi-C type of language). www.whosaway.com

Well, firefox is clientside, so that does not matter,
and serverside coding is off-topic here if it is not Javascript.

[I use serverside Javascript regularily]
 
> Next, I will be scratching my head and trying to re-learn AJAX. 

Why?

> Used it
> a few years ago successfully. Since then, I've lost a lot of what I
> knew, and what I knew was then incomplete, wrong and now certainly
> out-of-date. 

There is not much to learn, it is just interaction with a serverside page,
without leaving the clientside page.

>     I am still bothered that 'onkeyup'  is invisible to FF, whereas the 
> three others I tested work for me 

I really do not believe you on your word, 
it would have been world news for the last 20 years. 

Wouldn't it be that your code is faulty, and that other browsers are more 
forgiving? Did you debug?

This works fine here, also in Firefox:

<textarea onkeyup='alert("Hi!");'></textarea>


> as Iexpected.

MS-Ie?

> Thanks for all the constructive suggestions above !  Will ensure they
> are implemented as you detailed.

NO! You should not ensuredly implement it, but 

1 try to understand it.

2 then test it thoroughly. 

Don't trust me, I might make an error like anyone else.
[even while some might think they do not]


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#32152 — Re: onkeyup in Firefox

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-01-09 19:09 +0100
SubjectRe: onkeyup in Firefox
Message-ID<2131200.jE0xQCEvom@PointedEars.de>
In reply to#32149
Mel Smith wrote:

> Also, I did quite a bit of google searching. Many others complained of
> "onkeyup" not executing a specific function with Firefox

And you do not even remember what the "function" was, right?  But "many 
others" said Firefox was the problem, therefore you just believed it.
Cargo cult programming.

Probably it was a this.focus() _method_ call (or equivalent), and probably 
those people were attempting to force the user to type something in that 
field because it was "required".  Such script-kiddie approaches to Web 
development are averted by the Firefox/Gecko UX people.  AISB.
 
> Anyway, my text field of has a max length of 3 chars and will (later) be
> followed by several other fields. I wish each of this to be 'blurred' when
> a user tabs or <return>s.

That is why, AISB, you should handle the “keyup” event at a common ancestor 
element instead.
 
> Another also: my logical vrbl 'gotret' is global and is set to false on
> entry to the validate() function. If a <return> is sensed, it is set to
> true.

One of the first rules of thumb in programming is to avoid global variables.
 
> I only want chkforret() set the 'gotret' vrbl -- nothing further.

Usenet is not what you want.  And I, for one, am not someone who will help 
you eating your soup with a knife, so that you will eventually cut your 
tongue in the process, because a knife is the only tool that you presently 
know; I am someone who introduces the spoon to you instead.  Which I did.
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web