Javascript历史记录功能不适用于iOS 6主屏幕上提供的网页 [英] Javascript history function not working for web page served from homescreen on iOS 6

查看:118
本文介绍了Javascript历史记录功能不适用于iOS 6主屏幕上提供的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到一些关于iOS 6的新行为的帖子,其中网站已保存到主屏幕/从主屏幕启动。在iOS 5(及更早版本)上,我们能够将Javascript History功能用于我们的应用程序后退按钮。但是,在iOS 6中,如果您只访问过网站中的一个页面,则可以使用它。但是,如果您访问过多个页面,则会引发页面未找到错误。它在Safari中工作正常(不是来自主屏幕),如果我删除< meta name =apple-mobile-web-app-capablecontent =yes/> 标签。但后来我得到了我试图避免的丑陋的浏览器chrome。

I've seen some other posts about iOS 6's new behaviors with Web sites saved to / launched from the home screen. On iOS 5 (and earlier), we were able to use the Javascript History function for our in-app back button. In iOS 6, however, it works if you've only been to one page in the site. But if you have more than one page that you've visited, it throws a page-not-found error. It works fine in Safari (not from the homescreen), and it works if I remove the <meta name="apple-mobile-web-app-capable" content="yes" /> tag. But then I get the ugly browser chrome that I'm trying to avoid.

我看过类似的帖子,关于iOS 6的更改不再与Safari共享数据,但我希望有人遇到类似的问题,历史信息是存储/用于iOS 6中的应用程序的主屏幕版本。

I've seen similar posts about the changes to iOS 6 no longer sharing data with Safari, but I was hoping someone had run into a similar issue with the history information being stored / used for the homescreen version of the apps in iOS 6.

我们正在使用此调用:< a href =javascript: history.back(); class =back>< / a>

We're using this call: <a href="javascript:history.back();" class="back"></a>

再一次,它在Safari中工作正常,在所有旧操作系统中都很好。但是当用户点击的页面超过两页时,它在主屏幕上的iOS 6上失败。

Again, it's working fine from Safari, fine in all of the old operating systems. But it fails on iOS 6 from the homescreen when there are more than two pages that the user has clicked on.

推荐答案

我的理解如果您添加 apple-mobile-web-app-capable 标记,它会缓存添加到主屏幕的页面。

My understanding is that if you add the apple-mobile-web-app-capable tag - it caches the page that is bookmarked to the home screen.

启动书签后的任何后续请求都会导致Safari浏览器启动网址(添加了丑陋的Chrome)。

Any subsequent requests once the bookmark is launched will cause the safari browser to launch the url (with ugly chrome added).

你可以做一些基本的错误检查 - 如果有的话是历史记录:

You could do some basic error checking - if there is any history:

function GoBack() {
   if(history.length) {
       history.back();
       return false;
   }
   return true; //follow the regular link
}

你真的应该给你的网址一个合适的改为href值:

And you really should be giving your urls a proper href value instead:

<a href="http://your_standard_url" class="back" onClick="GoBack()"></a>

这篇关于Javascript历史记录功能不适用于iOS 6主屏幕上提供的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆