history.back() not working in phonegap ios build

2019-09-22 14:44发布

问题:

Creating a nice little phonegap build for ios at the moment, runs fine in the browser, however, when I compile it in Xcode and run in the simulator the history.back() I'm using doesn't work.

I need the history.back() in order to create a back button on each page in the app.

Does anyone know why this may be the case, or an alternative solution.

More information: phonegap build using ember js

回答1:

Yes, exactly. In several version iOS, Android ( old), history.back() seem not working. To fix it, you should try this code ( i find it in JQM @@ and it working well for all )

            var nav = window.navigator;
            if( this.phonegapNavigationEnabled &&
                nav &&
                nav.app &&
                nav.app.backHistory ){
                nav.app.backHistory();
            } else {
                window.history.back();
            }