0

我有一个在 iPhone/iPad 上的 iOS 7 中运行的 phonegap 应用程序。我在用着

history.back()

返回上一页的方法,但效果不佳。这就是我得到的:

  1. 我启动我的应用程序。吃完午饭它会加载我的主页;
  2. 我单击一个链接以加载第 1 页;
  3. 我单击一个back按钮,将历史记录作为操作返回,但它不起作用;
  4. 我单击一个链接以加载第 2 页;
  5. 我单击一个back按钮,将历史记录作为操作返回……它可以工作并显示第 1 页;
  6. 我单击一个back按钮,将历史记录作为一个动作返回,但它不再起作用;

如果当我启动我的主页时我重新加载它,该history.back方法总是有效......

错误在哪里?

4

1 回答 1

1

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>';
}
于 2013-11-05T04:46:06.027 回答