explicitOriginalTarget

explicitOriginalTarget

本文介绍了crossbrowser等价于explicitOriginalTarget事件参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道crossbrowser等价于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).

这篇关于crossbrowser等价于explicitOriginalTarget事件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:17