TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
phanikumar kowta
NA
5
16.6k
How to disable Browser Back button in asp.net application
Jul 18 2012 1:23 AM
Hi, Recently i got a requirement, to disable browser back button through out application. I tried with different ways like
function disableBackButton() { window.history.forward() }
disableBackButton();
window.onload = disableBackButton;
window.onpageshow = function(evt) { if (evt.persisted) disableBackButton() }
window.onunload = function() { void (0) }
I put the above code in master page, but in some scenario this is not working fine, and more over when i click browser back button page is loading.
After then I tried with following code. Put the follwoing code in Master page Header section.
<script type="text/javascript">
function changeHashOnLoad() {
window.location.href += "#";
setTimeout("changeHashAgain()", "50");
}
function changeHashAgain() {
window.location.href += "1";
}
var storedHash = window.location.hash;
window.setInterval(function() {
if (window.location.hash != storedHash)
{ window.location.hash = storedHash; } }, 50);
</script>
<body onload ="changeHashOnLoad();">
Using the above code the browser back button will not work in all browsers and page loading also avoided.. I hope itwill work fine.
With Regards
Phanikumar Kowta
Reply
Answers (
5
)
Delete Function
my data grid view dosent updated