android - Phonegap - navigator.app.backHistory() not working on HTML back button -


in app using phonegap 2.6.for button, using following function

document.addeventlistener("backbutton", onbackkeydown, false);  function onbackkeydown() {     alert("hello");     navigator.app.backhistory(); }  document.addeventlistener('deviceready', ondeviceready, true); 

the above function works fine when click on device's hardware button. when click on button not working.

i have designed button below:

<a class="ui-link" href="#" rel="external" onclick="onbackkeydown()">         <img src="images/icon-back.png" alt="phone" border="0"> </a> 

but button working fine navigator.app.exitapp(); (application exit).

//working fine function onbackkeydown() {     navigator.app.exitapp(); }  //not working function onbackkeydown() {     navigator.app.backhistory(); } 

but not working navigator.app.backhistory();.

i have tried 3 separate things when faced same situation:

  • window.history.back()

  • navigator.app.backhistory();

  • history.go(-1);

individually, none of these solve problem. put 3 things , surprise worked. don't know behind it.

then decreased 2 functions , removed:

  • window.history.back()

now using function , working fine.

//works fine function onbackkeydown() {     history.go(-1);     navigator.app.backhistory(); } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -