无法将焦点设置为在Chrome扩展程序中输入 [英] Can't set focus to input in chrome extension
本文介绍了无法将焦点设置为在Chrome扩展程序中输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
出于某种原因,我无法将焦点放在我的popup.html中的texbox上。以下是我迄今为止所尝试的内容:
popup.html:
< input type =textid =textboxname =aNamevalue =placeholder =blah/>
popup.js:
//尝试1
$(function(){
$('#textbox')。focus();
});
//尝试2
setTimeout(function(){$('#textbox')。focus();},1000);
我也试过没有javascript,只使用autofocus属性:
< input type =textid =textboxname =aNamevalue =placeholder =blahautofocus /> b
$ b popup-textarea-focus%22asas%22>但这一切都没有奏效... 任何想法?
注意:
- popup.js正在被调用,如果我把console.log()我得到输出
- 弹出窗口是由我们旁边的一个图标触发的(default_icon)
解决方案最后我用了这个:
popup.html:
< input type =textid =textboxname =aNamevalue =placeholder =blahautofocus />
popup.js:
$(function(){
if(location.search!=?focusHack)location.search =?focusHack;
});
感谢 Tarek El-Mallah 和 PAEz !!!
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)
解决方案 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!!!
这篇关于无法将焦点设置为在Chrome扩展程序中输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文