document.createEvent(" MouseEvents")适用于IE9和Firefox,但不能用于IE8! [英] document.createEvent("MouseEvents") is working for IE9 and Firefox, but can't for IE8!!!

查看:1032
本文介绍了document.createEvent(" MouseEvents")适用于IE9和Firefox,但不能用于IE8!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,为IE 8浏览器替换它的方式是什么?谢谢!


我需要模拟鼠标点击特定元素,


以下代码都在IE9和firefox中工作,但是IE8可以' t支持document.createEvent,那么我可以使用其他任何方法吗?


var evt1 = document.createEvent(" MouseEvents");

                      evt1.initMouseEvent(QUOT;按一下[;,真,真实的,窗口,

             &NBSP ;     0,0,0,0,0,false,false,false,false,0,null);


document.activeElement.dispatchEvent(evt1 );


解决方案

hii,


你看看样本是否在你的ie8中工作,如果有效,它不应该
document.createEvent(" MouseEvents")的问题。


https://developer.mozilla.org/samples/domref/dispatchEvent.html


Is any one can tell me what is the way that can I replace it for IE 8 browser ? thanks!

I need to simulate mouse click on the specific element,

the below code are all working in IE9 and firefox, but IE8 can't support document.createEvent, So Is there any other method I can use ?

var evt1 = document.createEvent("MouseEvents");
                      evt1.initMouseEvent("click", true, true, window,
                        0, 0, 0, 0, 0, false, false, false, false, 0, null);

document.activeElement.dispatchEvent(evt1);

解决方案

hii,

you see if the sample works in your ie8, if work, it should not document.createEvent("MouseEvents") 's problem.

https://developer.mozilla.org/samples/domref/dispatchEvent.html


这篇关于document.createEvent(" MouseEvents")适用于IE9和Firefox,但不能用于IE8!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆