我在IE9中遇到了一个奇怪的问题。
如果我将一个输入元素放在一个颜色框(内联HTML)中,然后按下输入键,所述输入元素具有焦点 - 颜色框关闭?
这不会发生在Chrome中。
我已经设置了一个jsfiddle来演示这个问题:
我无法在选项中看到任何可以预防/解释这个行为的内容吗?
如何阻止Enter关闭彩色框,而不是在所有输入元素上捕捉按键事件?
我已快速查看了colorbox源代码并注意到了escKey: true,
之类的参数,但是我无法解释这个问题来解释这个Enter Key问题?
修改:
如果我将以下内容添加到publicMethod.close()
alert("caller is " + arguments.callee.caller.toString());
它告诉我。publicMethod.close()
如果我添加以下内容(请注意使用caller.caller进一步向上移动):
alert("caller is " + arguments.callee.caller.caller.toString());
我得到以下内容:
---------------------------
Message from webpage
---------------------------
caller is
function( event ) {
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( event );
var i, ret, handleObj, matched, j,
handlerQueue = [],
args = core_slice.call( arguments ),
handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event;
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
return;
}
// Determine handlers
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
// Run delegates first; they may want to stop propagation beneath us
i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem;
j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
.apply( matched.elem, args );
if ( ret !== undefined ) {
if ( (event.result = ret) === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
}
}
// Call the postDispatch hook for the mapped type
if ( special.postDispatch ) {
special.postDispatch.call( this, event );
}
return event.result;
}
---------------------------
OK
---------------------------
所以colorbox.close()方法是由JQuery函数调用的吗?现在我只需要找出原因......
神秘感加深了......
答案 0 :(得分:0)
这似乎已经修复 - 无法在colorbox v1.4.33(2013-10-31)中重新创建问题