I'm developing a phonegap app based on jQuery mobile.
I'm trying to put a button in my app, behaving like back button on android devices. I don't want just a history.back()
, but I want the exactly same behavior, means going back when no handler is attached, and performing the handler when one is attached to the event backbutton
.
In other words, I want to simulate hardware back button, in software (exactly same behavior)
I've tried these codes, with no success:
$("#backbtn").click(function(){
var backButtonEvent = document.createEvent('Events');
backButtonEvent.initEvent('backbutton', false, false);
document.dispatchEvent(backButtonEvent);
});
What can I do?