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


Groups > comp.lang.javascript > #32328

Re: Having to click TWICE for event

From Cezary Tomczyk <cezary.tomczyk@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Having to click TWICE for event
Date 2017-01-25 09:32 +0100
Organization csiph.com Internet News Service
Message-ID <o69nqh$1pbj$1@csiph.com> (permalink)
References (3 earlier) <o6612n.998.1@mid.maikkoenig.de> <14f9d324-b305-499b-a9f4-dcc4729413ce@googlegroups.com> <77c28034-be7c-4ac6-a967-6d93c83d18a5@googlegroups.com> <o68e5f$onm$1@csiph.com> <18e749d1-3689-4f2d-8dd1-79b6ec4e5d3e@googlegroups.com>

Show all headers | View raw


On 25/01/2017 08:00, bit-naughty@hotmail.com wrote:
> On Tuesday, January 24, 2017 at 2:41:24 PM UTC-6, Cezary Tomczyk wrote:
>> On 24/01/2017 19:27, Ram Tobolski wrote:
>>>> And then how do you code the link?
>>>
>>> Hi. You don't need the link (<a>), just the <div>. You are registering a listener to clicks on the <div>
>>
>> That's not a good idea as the <div> itself is not focusable and the user
>> will not be able to reach this button using keyboard. Except when you
>> add attribute tabindex="0", but I'd rather not use <div> with click
>> event instead use natively focusable <a> HTML element.
>
>
> ...and what would the code look like? <a href=something id=something> ? That doesn't look right...?

<a> should works fine. However, seems <a> here is meant to be a button 
so I think you can consider here to use <button> instead.

<button id="openPopUp">Open popup</button>

var openPopUpButton = document.getElementById('openPopUp');

function openPopUp(event) {
     if (typeof event.preventDefault === 'function') {
         event.preventDefault();
     }

     // Code that opens pop up here
}

openPopUpButton.addEventListener('click', openPopUp);

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/
https://www.aslint.org/ - Accessibility linting tool

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


Thread

Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-22 22:55 -0800
  Re: Having to click TWICE for event Maik Koenig <usenetspam@maikkoenig.de> - 2017-01-23 09:08 +0100
    Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-23 10:47 -0800
      Re: Having to click TWICE for event Maik Koenig <usenetspam@maikkoenig.de> - 2017-01-23 22:45 +0100
        Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-24 06:00 -0800
          Re: Having to click TWICE for event Ram Tobolski <ramtob@gmail.com> - 2017-01-24 10:27 -0800
            Re: Having to click TWICE for event jonas.thornvall@gmail.com - 2017-01-24 10:55 -0800
            Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-24 11:05 -0800
              Re: Having to click TWICE for event Ram Tobolski <ramtob@gmail.com> - 2017-01-24 13:10 -0800
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-24 22:56 -0800
                Re: Having to click TWICE for event Maik Koenig <usenetspam@maikkoenig.de> - 2017-01-25 11:55 +0100
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-25 07:03 -0800
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-26 23:59 -0800
                Re: Having to click TWICE for event Ram Tobolski <ramtob@gmail.com> - 2017-01-25 11:05 -0800
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-24 23:25 -0800
                Re: Having to click TWICE for event Maik Koenig <usenetspam@maikkoenig.de> - 2017-01-25 11:57 +0100
                Re: Having to click TWICE for event Ram Tobolski <ramtob@gmail.com> - 2017-01-25 11:14 -0800
            Re: Having to click TWICE for event Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-01-24 21:41 +0100
              Re: Having to click TWICE for event Ram Tobolski <ramtob@gmail.com> - 2017-01-24 13:13 -0800
              Re: Having to click TWICE for event "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-24 23:46 +0100
                Re: Having to click TWICE for event Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-01-25 00:20 +0100
                Re: Having to click TWICE for event "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 11:19 +0100
              Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-24 23:00 -0800
                Re: Having to click TWICE for event Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-01-25 09:32 +0100
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-25 07:05 -0800
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-26 23:58 -0800
                Re: Having to click TWICE for event Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-01-27 12:48 +0100
                Re: Having to click TWICE for event Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-27 13:13 +0100
              Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-24 23:03 -0800
                Re: Having to click TWICE for event "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 11:21 +0100
                Re: Having to click TWICE for event bit-naughty@hotmail.com - 2017-01-25 07:10 -0800
                Re: Having to click TWICE for event "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 17:42 +0100

csiph-web