那是我吗?这是我的IE吗?或者为什么这段代码不适用于IE 11:
var clicker = new MouseEvent("click", {
'bubbles': true,
'cancelable': true,
'view': window,
'detail': 0,
'screenX': 0,
'screenY': 0,
'clientX': 0,
'clientY': 0,
'ctrlKey': false,
'altKey': false,
'shiftKey': false,
'metaKey': false,
'button': 0,
'relatedTarget': null
});
Run Code Online (Sandbox Code Playgroud)
我在控制台上得到"对象不支持此操作"(F12).我不得不提出一个解决方法,但我只是不明白为什么以前的代码不起作用(顺便说一句,以前的代码来自这里:https://msdn.microsoft.com/en-us/library /ie/dn905219 ( v=vs.85).aspx(创建和解雇合成事件).解决方法:
if (typeof MouseEvent !== 'function') {
(function (){
var _MouseEvent = window.MouseEvent;
window.MouseEvent = function (type, dict){
dict = dict || {};
var event = document.createEvent('MouseEvents');
event.initMouseEvent(
type,
(typeof dict.bubbles == 'undefined') ? true : …Run Code Online (Sandbox Code Playgroud)