防止退格键使页面后退的代码

<script>
        $(document).ready(function () {
            $(document).keydown(function (e) {
                var doPrevent;
                if (e.keyCode == 8) {
                    var d = e.srcElement || e.target;
                    if (d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA') {
                        doPrevent = d.readOnly || d.disabled;
                    }
                    else
                        doPrevent = true;
                }
                else
                    doPrevent = false;

                if (doPrevent)
                    e.preventDefault();
            });
        });
    </script>

展开阅读全文

没有更多推荐了,返回首页