且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在浏览器中禁用后退和前进按钮?

更新时间:2023-12-03 08:36:46

请探索



http://www.outsystems.com/forums / discussion / 8465 / disable-the-back-and-forward-buttons-on-browser / [ ^ ]



http://www.javaprogrammingforums.com/ javaserver-pages-jsp-jstl / 7185-how-disable-forward-backward-buttons-using-javascript.html [ ^ ]


hi,



请参阅以下示例对您有用。



 <   html  >  
< head >
< title > 使用JavaScript < / title >

< script type = text / javascript src = http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js > < / script >
< script 类型 = text / javascript src = http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js >
< / sc ript >
< / head >

< body style = font-family:Arial; font-size:15px; >
< a href = Page2.htm > 点击此处... < / a >
< / body >

< script >


(document).ready(function(){
function disableBack(){window .history.forward()}

window.onload = disableBack();
window.onpageshow = function(evt){if(evt.persisted)disableBack()}
});

< / script >
< / html &GT; 跨度>


Hi guys,

can we disable back and forward button in browser.please provide the solution.

Thanks and regards
Amar

Please explore

http://www.outsystems.com/forums/discussion/8465/disable-the-back-and-forward-buttons-on-browser/[^]

http://www.javaprogrammingforums.com/javaserver-pages-jsp-jstl/7185-how-disable-forward-backward-buttons-using-javascript.html[^]


hi,

Refer below example is useful to you.

<html>
<head>
    <title>Disable Browser Back Button Using JavaScript</title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js">
        </script>
</head>

<body style="font-family:Arial;font-size:15px;">
    <a href="Page2.htm">Click Here...</a>
</body>

<script>


(document).ready(function() { function disableBack() { window.history.forward() } window.onload = disableBack(); window.onpageshow = function(evt) { if (evt.persisted) disableBack() } }); </script> </html>