开发者

"-moz-user-focus" doesn't work?

I've made this sample:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window width="400" height="300"
 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

   <textbox id="textBox1"/>
   <textbox id="textBox2" style="-moz-user-focus: ignore;"/>
   <textbox id="textBox3"/>
</window>

And, at least here, the style applied to the second textbox is doing nothing. I expected it to avoid the user focus, as the doc says.

Does someone experienced this?

--edit

To whom it may concern, the working version:

<window width="400" height="300"
 onload="document.getElementById('textBox2').tabInde开发者_开发技巧x='-1';"
 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

   <textbox id="textBox1"/>
   <textbox id="textBox2" onmousedown="return false;"/>
   <textbox id="textBox3"/>
</window>


The textbox itself never takes focus. Instead, XBL creates an anonymous XHTML input element inside the textbox, and this is what takes focus. You can stop the textbox taking keyboard focus by setting its tab index to -1, and mouse focus by preventing the default action of mousedown events.

Another approach is to set the textbox to disabled or readonly, depending on why you don't want the textbox to be focused.


I opened a bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=627691

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜