【发布时间】:2011-11-25 13:39:47
【问题描述】:
我正在做一个 Firefox 扩展。该扩展程序有一个侧边栏。在这个侧边栏中,我动态创建了一些文本框。如何将焦点放在我创建的最后一个文本框上?
这是代码,我想把焦点放在文本框 "userResponse" 中。文本框是一个 XUL 元素。
var textResponse= document.createElement("textbox");
textResponse.setAttribute("id", "userResponse");
textResponse.setAttribute("class", "question");
textResponse.setAttribute("title", "Type your question here");
textResponse.onkeypress = numberOfResults;
textResponse.focus("");
var trResponse = document.createElement("tr");
var tdResponse = document.createElement("td");
tdResponse.appendChild(textResponse);
trResponse.appendChild(tdResponse);
tableQuestion.appendChild(trResponse);
我用document.getElementById("userResponse").focus() 试过了,但没有用。
【问题讨论】:
标签: javascript firefox firefox-addon xul