问题描述
有谁知道跨浏览器等效于explicitOriginalTarget 事件参数?此参数是 Mozilla 特定的,它为我提供了导致模糊的元素.假设我的页面上有一个文本输入和一个链接.文本输入具有焦点.如果我点击链接,文本输入的模糊事件会通过explicitOriginalTarget 参数为我提供Firefox 中的链接元素.
Does anyone know of crossbrowser equivalent of explicitOriginalTarget event parameter? This parameter is Mozilla specific and it gives me the element that caused the blur. Let's say i have a text input and a link on my page. Text input has the focus. If I click on the link, text input's blur event gives me the link element in Firefox via explicitOriginalTarget parameter.
我正在扩展 Autocompleter.Base 的 onBlur 方法,以便在搜索字段失去对给定元素的焦点时不隐藏搜索结果.默认情况下,如果搜索字段失去对任何元素的焦点,onBlur 方法将隐藏.
I am extending Autocompleter.Base's onBlur method to not hide the search results when search field loses focus to given elements. By default, onBlur method hides if search-field loses focus to any element.
Autocompleter.Base.prototype.onBlur = Autocompleter.Base.prototype.onBlur.wrap(
function(origfunc, ev) {
var newTargetElement = (ev.explicitOriginalTarget.nodeType == 3 ? ev.explicitOriginalTarget.parentNode: ev.explicitOriginalTarget); // FIX: This works only in firefox because of event's explicitOriginalTarget property
var callOriginalFunction = true;
for (i = 0; i < obj.options.validEventElements.length; i++) {
if ($(obj.options.validEventElements[i])) {
if (newTargetElement.descendantOf($(obj.options.validEventElements[i])) == true || newTargetElement == $(obj.options.validEventElements[i])) {
callOriginalFunction = false;
break;
}
}
}
if (callOriginalFunction) {
return origFunc(ev);
}
}
);
new Ajax.Autocompleter("search-field", "search-results", 'getresults.php', { validEventElements: ['search-field','result-count'] });
谢谢.
推荐答案
在基于 Gecko 的浏览器之外的任何浏览器中都没有与explicitOriginalTarget 等效的内容.在 Gecko 中,这是一个内部属性,不应由应用程序开发人员(可能由 XBL 绑定编写者)使用.
There is no equivalent to explicitOriginalTarget in any of the other than Gecko-based browsers. In Gecko this is an internal property and it is not supposed to be used by an application developer (maybe by XBL binding writers).
这篇关于等效于explicitOriginalTarget 事件参数的跨浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!