Mouseover event doesn't granulate on IE9 for sub elements, event doesn't start on IE8

前端 未结 5 475
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 01:03

We were adapting a method posted here highlight a DOM element on mouse over, like inspect does to NOT use jQuery.

We came up with this solution so fa

5条回答
  •  天命终不由人
    2021-01-02 01:38

    Using a special routine for Internet Explorer (tested in IE9, not tested in IE8), I have come up with this. However, it is not perfect, yet. When moving the mouse inside the same element, flickering occurs as the routine is run multiple times (and sometimes the overlay disappears completely). I hope to perfect this soon.

    Routine:

    • I specifically checked if the browser was IE and performed the following actions:
    • I assigned the mousemove event to a function that uses document.elementFromPoint(x, y).
    • I assigned mouseover to a clearing function, that removes the overlay immediately. (This causes the flickering and a possible complete overlay removal, even though the mouse is still on the element.)

    Element From Point Function

    function ep(e)
    {
        var ev = {target:document.elementFromPoint(e.clientX, e.clientY)};
        handler(ev);
    }
    

    Clearing Function

    function clear(e)
    {
       cur = null;
       overlay.style.display='none';
    }
    

    Feedback and suggestions are welcome. I am still working on this, and I will post updated JSFiddle links.

提交回复
热议问题