首先要提醒任何正在使用IE的用户(在Chrome、Safari或Firefox中不会出现此问题)- 小提示 ;)
那么...我在IE中遇到了有关工具提示的问题,我为所有可悬停元素添加了一个onmouseover
监听器,然后在我的mouseover
函数中,我有一个非常基本的跨浏览器声明,如下所示...
var event = e || window.event,
el = event.target || event.srcElement;
我一直遇到 window 对象在 IE 中不存在的问题,这是我在添加一个标志以忽略从一个元素的 mouseover 到工具提示本身(在允许的时间循环内,300ms)时出现的问题。换句话说,该标志是为了忽略从原始 mouseover 到工具提示的路线上的鼠标悬停事件。
因此,该逻辑如下所示...
loadtip.refMouseOver = function (e) {
var event = e || window.event, el = event.target || event.srcElement;
//console.log(window); // <-- throws error in IE (Member not found)
// Reset the lastHoveredRef data.
tipManager.lastHoveredRef = null;
tipManager.lastHoveredRef = [el, event];
// true means there is a tip open still, so if no tip is open.
if (tipManager.tipState !== true) {
tipManager.processTip(el, event);
} else {
return; // do nothing
}
}
当我在IE中快速从一个元素悬停到另一个元素时,如果工具提示仍然打开,则会出现“未找到成员”错误。
我阅读了关于使用try catch和 window.open
的文章,但我不知道它们如何相关。非常感谢任何帮助。