How to stop page loading when click on F5

青春壹個敷衍的年華 提交于 2019-12-10 00:38:09

问题


How to stop the page loading when click on F5...

Thanks & Regards

Rubina


回答1:


For IE and FireFox

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block F5 Key In IE & Mozilla</title>

<script language="JavaScript">

    var version = navigator.appVersion;

    function showKeyCode(e) {
        var keycode = (window.event) ? event.keyCode : e.keyCode;

        if ((version.indexOf('MSIE') != -1)) {
            if (keycode == 116) {
                event.keyCode = 0;
                event.returnValue = false;
                return false;
            }
        }
        else {
            if (keycode == 116) {
                return false;
            }
        }
    }

 </script>

</head>
<body onload="JavaScript:document.body.focus();" onkeydown="return showKeyCode(event)">
</body>
</html>



回答2:


Try the below to disable location.reload() by overriding it as:

location.reload = function() {return false;}

But this may have other side-effects...



来源:https://stackoverflow.com/questions/12418803/how-to-stop-page-loading-when-click-on-f5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!