Javascript本机代码函数给出“foo不是函数”错误
我试图在Ekioh SVG浏览器中模拟键盘按键。它只支持不推荐使用的initKeyboardEvent事件构造函数 以下是我创建事件的代码:Javascript本机代码函数给出“foo不是函数”错误,javascript,input,Javascript,Input,我试图在Ekioh SVG浏览器中模拟键盘按键。它只支持不推荐使用的initKeyboardEvent事件构造函数 以下是我创建事件的代码: evt = document.createEvent('KeyboardEvent'); console.log(evt.initKeyboardEvent.toString()); // output: // evt.initKeyboardEvent:function initKeyboardEvent() { // [native code
evt = document.createEvent('KeyboardEvent');
console.log(evt.initKeyboardEvent.toString());
// output:
// evt.initKeyboardEvent:function initKeyboardEvent() {
// [native code]
// }
evt.initKeyboardEvent("keypress", true, true, window,
0, keyCode, false, "", 0);
// output:
// TypeError: evt.initKeyboardEvent is not a function at file:/foo.js:302
为什么它会被打印为函数,但我不能调用它?因为它是本机函数,也许它确实需要使用正确的签名来调用?你是什么意思?我该怎么做查看并修复您为该函数提供的参数。我的意思是,错误消息可能会产生误导;js函数实际上存在,但抱怨参数类型错误,因此找不到具有匹配签名的本机接口。