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


Groups > comp.lang.javascript > #32146

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

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject onkeyup in Firefox (was: onkeyup not working for me in FireFox 50.1.0)
Date 2017-01-09 00:30 +0100
Organization PointedEars Software (PES)
Message-ID <7279249.NyiUUSuA9g@PointedEars.de> (permalink)
References <edfu3kFkfvbU1@mid.individual.net>

Show all headers | View raw


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.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web