防止iE11中的默认“F1”事件 [英] prevent default 'F1' event in iE11

查看:234
本文介绍了防止iE11中的默认“F1”事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户按F1键时,我打算显示我们的应用程序帮助并禁止默认操作。
我尝试使用不同的选项不显示IE的弹出窗口。
这是我的代码:

When the user press F1 key,I am planning to display our application help and suppress default action. I tried with different options not to show help popup of IE. Here is my Code:

document.addEventListener('keydown', function (e) {
            if (e.key === 'F1' || e.keyCode == 112) {

                   e.cancelBubble = true;
                    e.cancelable = true;
                    e.stopPropagation();
                    e.preventDefault();
                    e.returnValue = false;

                //my help menu code goes here
            }
});

请让我知道如何实现我的应用程序的帮助页面,而不是IE帮助。
我正在使用IE11版本。

Please let me know how can i achieve in showing the help page of my application instead of IE help. I am using IE11 version.

推荐答案

您可以订阅 window.onhelp event:

You could subscribe to the window.onhelp event:

window.onhelp =function() { 
    alert();
    return false;
}

这篇关于防止iE11中的默认“F1”事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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