I have the exact same problem and have been trying to figure this one out for way to long. It seems like its a combination of data-ajax true or false, domcaching, etc. I'm using JQM, phonegap 3.0.0 to make a mobile, desktop, and IOS version that I want to work exactly the same
Here is what I did and it works so far. So basically if there are pages in history...show a back button, if not show the home button. I'll post more if I discover anything else.
function goBack(){
history.go(-1);
navigator.app.backHistory();
}
function goToUrl(x){
window.location=x;
}
if (history.length>1) {
backBtn = '<a href="javascript:goBack();" data-ajax="false" data-icon="arrow-l" data-iconpos="notext" class="ui-btn-left">Back</a>';
}else{
backBtn = '<a href="javascript:goToUrl(\'../home/index.html\');" data-icon="home" data-iconpos="notext" class="ui-btn-left">Home</a>';
}