简体   繁体   中英

Manipulate HTML5 application history

I have the following scenario for a PhoneGap mobile app:

  1. App opens and displays index.html
  2. User logs in and gets redirected to home.html
  3. User can then go to news.html
  4. I want to handle the back button in the home.html in a way that if the previous page (the one after you go back in history) was news.html, I want to browser to go back in history using navigator.app.backHistory(); . But if the previous page is the index.html, I want to close the app using navigator.app.exitApp();

My point is, after logging in, the user should never be able to land on index.html again.

Instead of doing this, do the following:

  1. App opens and displays index.html
  2. User logs in and gets redirected to home.html using History API you replace the current state of the page with "home.html" by using history.replaceState()
  3. Now the user "never was" on index.html in the first place

Read about manipulating the browser history . This should work with Phonegap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM