1

I have created a chrome extension with a simple popup.html file that contains a button tag as first element inside the body. When I test it on Chrome 26 under OS X, each time I click on my extension icon that triggers the popup, my button seems selected/focused given that I see it with a blue halo. I cannot figure out how to disable auto focus. It seems autofocus is applied on the first tag from the popup.html file. I tried to apply blur() on the button instance retrieved with document.getElementById but it does not work.

Is there any solution? workaround? alternative?

Laurent
  • 14,122
  • 13
  • 57
  • 89

2 Answers2

4

The only solution I found consists of adding tabindex="1" on the html tag. I tried to put focus on other elements or to use autofocus="autofocus" but this does not work.

Laurent
  • 14,122
  • 13
  • 57
  • 89
1

You can set focus to element either by js el.focus() or by the new html5 autofocus="autofocus" attribute You cannot remove focus from an element unless you set focus on some other element - so you can set focus on some bogus anchor element or something to remove the focus from your button

Adidi
  • 5,097
  • 4
  • 23
  • 30