我不知道例程setSelectionRange文本框在新的Firefox夏天不起作用。在MDN站点(Mozilla开发中心)将其指定:XUL文本框setSelectionRange
setSelectionRange(开始,结束) 返回类型:无 设置的文本框,其中,所述开始参数是的索引的选择的部分的返回值要选择的第一个字符和结束参数是选择后字符的索引 。将两个参数都设置为 具有相同的值,以将光标移动到相应位置 而不选择文本。
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:h="http://www.w3.org/1999/xhtml">
<button label="x" oncommand="sel()" />
<textbox id="id" multiline="true"
value="This is some text that could wrap onto multiple lines."/>
<script type="text/javascript">
<![CDATA[
function sel(){
var textbox = document.getElementById("id");
textbox.setSelectionRange(1 , 2);
}
]]>
</script>
</window>
https://developer.mozilla.org/en/XUL_Tutorial/Focus_and_Selection – linguini 2012-04-20 06:07:11