码迷,mamicode.com
首页 > Web开发 > 详细

js监听键盘提交表单

时间:2019-01-17 12:49:51      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:==   fun   nbsp   div   iss   登陆   火狐浏览器   cti   orm   

<!DOCTYPE html>
<html>
<head>
<title>登陆系统</title>
<link href="/nmm/Public/User/css/user.css" rel="stylesheet">
<link href="/nmm/Public/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="/nmm/Public/js/jquery.min.js"></script>
<script type="text/javascript" src="/nmm/Public/User/js/user.js"></script>
<script type="text/javascript">
        if (top.window !== window) {
                top.location = window.location;
        }

        //执行键盘按键命令
        function keyDown(e) {
                var keycode = 0;
                //IE浏览器
                if (CheckBrowserIsIE()) {
                        keycode = event.keyCode;
                } else {
                        //火狐浏览器
                        keycode = e.which;
                }
                if (keycode == 13) //回车键是13
                {
                        $("#btn-save").click();
                }
        }
        //判断访问者的浏览器是否是IE
        function CheckBrowserIsIE() {
                var result = false;
                var browser = navigator.appName;
                if (browser == "Microsoft Internet Explorer") {
                        result = true;
                }
                return result;
        }
</script>
</head>

<body class="login" onkeydown="keyDown(event);">
        <form name="forms">
                <div class="login_m">
                        <div class="login_logo">
                                <h1>NMM 信息发布系统</h1>
                        </div>
                        <div class="login_boder">
Type  :quit<Enter>  to exit Vim                                                                                                  47,4-25       29%
                                                <button type="button" id="btn-save" class="btn btn-primary"
                                                        onclick="return check();">登陆</button>
                                        </p>
                                </div>
                        </div>
                </div>
                <div class="text-center">
                       
                </div>
        </form>

        <!-- Modal -->
        <div class="modal fade" id="msgModal">
                <div class="modal-dialog">
                        <div class="modal-content">
                                <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">
                                                <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                                        </button>
                                        <h4 class="modal-title" id="msgModalLabel"></h4>
                                </div>
                                <div class="modal-body text-center" id="msgModalBody"></div>
                                <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
                                </div>
                        </div>
                </div>
        </div>
</body>
</html>

 

js监听键盘提交表单

标签:==   fun   nbsp   div   iss   登陆   火狐浏览器   cti   orm   

原文地址:https://www.cnblogs.com/ylht/p/10281497.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!