Xul'l 浏览器焦点事件不起作用吗?
我有这个浏览器元素:
<?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">
<browser
id="mybrowser"
onclick="dump('CLICKED!\n')"
onfocus="dump('FOCUSED!\n')"
type="content"
src="http://www.google.com/"
flex="1" />
</window>
并且 onclick
运行良好,但 onfocus
运行不佳。两者都是从 DOM 元素 继承的,所以它应该可以工作。
知道为什么它不起作用吗?
obs. 我知道我可以通过向窗口添加焦点侦听器来使其工作。但我想知道为什么 onclick
被纠正继承并适用于浏览器元素,而 onfocus
则不然。
I have this browser element:
<?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">
<browser
id="mybrowser"
onclick="dump('CLICKED!\n')"
onfocus="dump('FOCUSED!\n')"
type="content"
src="http://www.google.com/"
flex="1" />
</window>
and the onclick
is working well, but not the onfocus
. Both are inherited from DOM element, so it should work.
Any idea why it's not working?
obs. I know I can make it work by adding a focus listener to the window. But I want to know why the onclick
is corrected inherited and working for the browser element, while the onfocus
not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是点击事件会冒泡,但焦点(和模糊)事件不会。 (加载和卸载事件略有不同,页面的 [i]frame 元素上的事件处理程序将像事件已冒泡一样触发。它们仍然不会冒泡到
;
.)我不知道为什么这些事件不会冒泡。
The answer is that click events bubble, but focus (and blur) events do not. (Load and unload events are slightly different in that an event handler on a page's [i]frame element will fire as if the event had bubbled. They still don't bubble to a
<browser type="content">
.)I don't know a reference for why these events don't bubble.