获取单击鼠标的分区Id
我正在尝试获取鼠标在其中被点击的Div ID,以便如果它在id('divContext')中没有被点击,它将隐藏('divContext').我现在的功能在FF中运行得很好,但在IE中就不行了.即使点击链接,div也不会消失.
选择 | 换行 | 行号
- //see if the focus has been taken off of the div and if so hide it.
- function on_down(e)
- {
- //alert('test');
- if (e == null) { e = window.event; }
- var evt = e.target || e.srcElement;
- //alert(evt.id);
- if (evt.id != 'divContext' && evt.id != 'aView' && evt.id != 'aComplete')
- {
- if (document.getElementById('divContext').style.display != 'none')
- {
- document.getElementById('divContext').style.display = 'none';
- }
- }
- }
- // See if a link in the div was clicked.
- function on_up(e)
- {
- if (e == null) { e = window.event; }
- var evt = e.target;
- //alert(evt.id);
- if (evt.id == 'aView' || evt.id == 'aComplete')
- {
- if (document.getElementById('divContext').style.display != 'none')
- {
- document.getElementById('divContext').style.display = 'none';
- }
- }
- }
- onload=function()
- {
- onmousedown = on_down;
- onblur = on_down;
- onmouseup = on_up;
- }
有人知道为什么这在IE中不起作用吗?