Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have .net website and i want to handle mobile back button without page reloading in javascript or jquery
Posted
Comments
Ajith K Gatty 14-Oct-14 2:08am    
try window.history.go(-1); But im not sure whether it reloads the page again.

You can use window.history.forward() on the page. But the thing is to understand what this does.
history.forward() moves the user to the next URL/Page that is in the history. If no URL/Page is there in the history, it simply gives nothing, it will not work.
And disabling the browsers Back button is to mess with browser's functionality.
Going back to the previous page or next page is the default behaviour of any browser. So we can hardly manipuate much of the functionalities. So, I guess we can prevent the back button getting fired by restricting the Url to the very next Url in the History.
Another case is if you want not to store the Url in the history of the page you can use the following bit of code:
C#
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)

Here we expire the cache from the program, i.e. clear the cache.

Hope you get some idea from this.
Thanks.
:)
 
Share this answer
 
if(event.keycode==27) is it works for mobile ??? i want to only hide the menu on mobile back button and if not page goes back page.... is it possible to add action on mobile back button in jquery
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900