Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto Focus in Google Chrome extension

I made a simple Chrome extension - search with a form.

When I open the extension, there is no default focus on form, but it requires additional click.

Focus is suppose to happen on popup.html form.

Now JavaScript .focus() method didn't work, Is there any other way to set default focus for Chrome extensions?

HTML:

<input type="text" id="mydata"  />

JS:

document.getElementById('mydata').focus();
like image 955
dd . Avatar asked Oct 17 '25 00:10

dd .


1 Answers

the latest chrome has supported tabindex attribute. So you can use

<input type="text" id="mydata" tabindex="1" />

to make it work without any js codes. just FYI.

like image 133
harrrrrrry Avatar answered Oct 18 '25 13:10

harrrrrrry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!