Can't set focus to input in chrome extension

google-chrome-extension, jquery

Solution

Finally what I've used is this:

popup.html:

<input type="text" id="textbox" name="aName" value="" placeholder="blah" autofocus />

popup.js:

$(function() {              
    if (location.search != "?focusHack") location.search = "?focusHack";
});

Thanks Tarek El-Mallah and PAEz!!!

Problem

For some reason I can't set focus on a texbox I have in my popup.html. Here's what I've tried so far: popup.html: ``` <input type="text" id="textbox" name="aName" value="" placeholder="blah" /> ``` popup.js: ``` //Attempt 1 $(function() { $('#textbox').focus(); }); //Attempt 2 setTimeout(function() { $('#textbox').focus(); }, 1000); ``` I also tried without javascript, using just the autofocus property: ``` <input type="text" id="textbox" name="aName" value="" placeholder="blah" autofocus /> ``` But none of this worked... Any ideas? Notes: - popup.js is being called, if I put console.log() I get the output - The popup is fired by an icon we have next to the omnibar (default_icon)

Original source

Related problems