Simulate Mouse Over in Vimperator plugin

梦想的初衷 提交于 2019-11-27 12:23:42

here's some code to start with to create the event, simpler and works for more browsers (if you don't need to specify exact mouse coordinates)

        if( document.createEvent ) {
            var evObj = document.createEvent('MouseEvents');
            evObj.initEvent( 'mouseover', true, false );
            elem.dispatchEvent(evObj);
        } else if( document.createEventObject ) {
            elem.fireEvent('onmouseover');
        }

hope that helps

TweeZz

In case anyone bumps into this looking for a framework agnostic way to fire any HTML and Mouse event (and set some options, if needed), have a look here: How to simulate a mouse click using JavaScript?

You may only trigger mouseover event on fields/elements that have a mouseover event bound to them. You can't just hijack the mouse.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!