I do not use Cordoba, but this code can help you:
String . prototype . isEmpty = function () { return this . length === 0; }; var browserHistory; function hash ( name, historyChange ) { "use strict"; if ( name !== undefined ) { if ( hash () !== name ) { if ( ! historyChange ) { browserHistory . add ( name ); } window . location . hash = name; } } else { var newHash = window . location . hash . split ( "#" ) [ 1 ]; return newHash === undefined ? "" : newHash; } } browserHistory = { currentIndex : 0, history : [], add : function ( name ) { "use strict"; this . currentIndex = this . currentIndex + 1; if ( this . history . length - 1 > this . currentIndex ) { this . history . splice ( this . currentIndex ); } this . history . push ( name ); }, backward : function () { "use strict"; if ( this . currentIndex === 0 ) { return; } this . currentIndex = this . currentIndex - 1; this . changeHash (); }, changeHash : function () { "use strict"; hash ( this . history [ this . currentIndex ], true ); }, forward : function () { "use strict"; if ( this . currentIndex === this . history . length - 1 ) { return; } this . currentIndex = this . currentIndex + 1; this . changeHash (); }, init : function ( name ) { "use strict"; this . history . push ( name ); } }; window . onhashchange = function () { "use strict"; if ( hash () . isEmpty () ) { load ( { name: "" } ); } else { load ( { name: hash () } ); } }; window . onload = function () { "use strict"; if ( ! hash () . isEmpty () ) { browserHistory . init ( hash () ); load ( { name: hash () } ); } else { browserHistory . init ( "" ); } };
This script:
1) Work with sites that use hashes (http (s): // (www.) Name.domain / # urlHash).
Examle: https://www.example.com/page - default url https://www.example.com/page#login - login subpage https://www.example.com/page
2) the function "window. Onload" checks if the entered url contains a hash and init browserHistory with it or with the help of "" (empty line) - no hash - this is my main page
3) Object "browserHistory" saves page history
4) The "hash" function, called without arguments, returns the current hash of the URL and, with the "name" url hash parameter changed
5) When the hash changes, the "window. Onhashchange" function is called 6) "Hond" the "window. Onhashchange" function If the url does not contain a hash, the script load the default page.
If the URL contains a hash, the script loads the hash-based subpage.
7) In the "load" function (not described here), I have an XMLHttpRequest that calls the php file with the name argument and sets the main div element that was returned from this php file to the html code.
8) Instead (for example):
<a class="a_nice_style" href="https:
You can use (for example):
<p class="a_nice_style" onclick="hash ( 'images' );">Images gallery</p>
9) A function named: "load" has an object as a parameter. This object is sent to the php file (as an array of "$ _GET" or "$ _POST"), so you can call the "load" function with a custom object that contains, for example, the values ββof the input fields. 10) "browserHistory" has only the hashes of your page.
This will be your onclick button:
onBackButton: function() { browserHistory . backward (); }
You can change the function "browserHistory. Backward" to exit the application by replacing: "return;" in this line:
if ( this . currentIndex === 0 ) { return; }
with the exit code of your application.