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
Post a Comment