3

When I click the buttons on a timeline, my browser(chrome) doesn't focus the button. The focus was stay on the element where it was. How do they do that?

enter image description here

These are what I found.

  • They don't use blur() function on click. If they call the method, the preexisting focus would disappear.
  • It seems they don't save previous focused element, and refocus it. When I overrided $.fn.focus method, it wasn't called.
  • They use some trick with JavaScript. When I disabled JavaScript, I managed to focus the element by clicking the buttons.
Sanghyun Lee
  • 21,644
  • 19
  • 100
  • 126
  • My guess (without looking at the code): They use `mouseup` instead of `click` and prevent the default action. Have you found the code for the buttons that triggers the action and shows the popup? – Bergi Dec 30 '14 at 11:58
  • No, I haven't. And, when I tested, it was not possible to prevent focusing clicked elements by preventing the default action. – Sanghyun Lee Dec 31 '14 at 07:57
  • Hm, what about preventing the `focus` event's action? – Bergi Dec 31 '14 at 18:32

1 Answers1

0

What you wanna do is focus on an element whenever you someone clicks on a certain element.

Click here to check out an example of how I would do it

This is what you are looking for

6 |    searchButton.focus();

UPDATE:
Your question is unclear, and you question is how does it keep the focus on the same element... and I showed you how..