0

When accessing an external page from a Cordova app, then coming back to app with back-button, the app page is empty, or more precisely, everything that was dynamically added to the page is gone. This seems to be the case whether the link is a native <a href="..."> or is accessed via window.open(), or via cordova.InAppBrowser.open(). The only way it does not happen is when the actual browser is specified via "_system" parameter.

Is there a way to prevent this, or is it normal behaviour ? Should I simply rebuild the dynamic page upon returning ? I could do that, but no event seems to be fired on return, not even a pageshow.

patb
  • 1,688
  • 1
  • 17
  • 21
  • Indeed, as @Jeff says, the app starts over altogether, same as an initial launch, thus all dynamic content is lost, (and so are javascript variables) and pages must be rebuilt, maybe after reloading data from `LocalStorage`. There is **one difference** as per initial app start: the active page is the one we left from, although its `pagebeforecreate` or `pagebeforeshow` are not called. Thus if your app was setting up the page on these events, your setup does not gets called. So on `deviceready`, you should call setup code for all pages, so they are rebuilt upon return from browser. – patb Nov 13 '15 at 17:40

1 Answers1

1

Navigating back refreshes (reloads) the page...so anything dynamically added to the page will correctly be gone. You could use hash tags on the URL for simple information or localStorage for more complex information about the page state and re-populate the page based on it when it reloads.

pageshow most like isn't firing because of some assumption being made in the JS code. Try listening to the $(document).ready for debugging purposes. It could also be caused by the issue described here (because of caching): 'pageshow' is not received when pressing "back" button on Safari on *IPad"

Specifying system causes the page to open in a new window...so that's

Community
  • 1
  • 1
Jeff
  • 35,755
  • 15
  • 108
  • 220