So, I am writing a simple webextension for Firefox. It uses the browserAction popup to receive some data from the user. This data is entered into the textArea element. It would be convenient for the user if the textArea element had focus when a pop-up window appeared. I thought it would be a relatively simple question to set focus in pop-up JavaScript, for example:
document.addEventListener('DOMContentLoaded', function(event) {
document.getElementById('texarea-id').focus();
});
However, this does not work.
After some research (setting other visible changes in this function and setting focus in other circumstances), it seems to me that the pop-up window has no focus on opening.
Is there a way to fix this and get focus when opening the browserAction popup?
source
share