stop back behaviour in android phone in web browser
-
13-11-2019 - |
Question
I have read this link
How can we stop web page view after sign-out using browser back
My problem is bit different
I have one webpage, in which viewing of div is controlled by JS
Now say initially I am on div1, once I click on change div icon, div2 appears and div1 is disappeared, now if someone presses back button on android it goes on previous page and i wanted to display div1 hiding div2.
any help??
Solution 2
Problem solved used onhashchange(), it helped.
OTHER TIPS
possible solution, whenever div2 appear create one method that sets a flag for div2, and call through JS. onBackPressed()
method just check that flag value is set or not, if yes then create another function that call JS function to disappear div2 and make div1 visible. And don't forget to reset the flag value.. This is just an idea as you don't have shared your code..