尽管避免了 HTML 'href' 链接,iOS 网络应用程序仍会打开 Safari [英] iOS web app opens Safari in spite of avoiding HTML 'href' links

查看:40
本文介绍了尽管避免了 HTML 'href' 链接,iOS 网络应用程序仍会打开 Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 IOS(在 9.2 上测试)网络应用程序(apple-mobile-web-app-capable)避免了 <a href="xxx"/>链接并仅使用 windows.location.replace(url) 等 Javascript 导航功能来导航到页面.

My IOS (tested on 9.2) web application (apple-mobile-web-app-capable) avoids <a href="xxx" /> links and uses only Javascript navigation functions like windows.location.replace(url) to navigate to the pages.

我的应用程序的根目录不是 www.xxx.com,而是 www.xxx.com/mysite.一些到 /mysite/xxx 的导航操作正在工作,但其他导航到 /mysite/yyy 会打开 Safari 窗口.除了 <a href="xxx"/> 链接之外,是否还有其他情况会导致 Web 应用程序在单独的 Safari 窗口中打开链接?

The root of my application is not www.xxx.com but www.xxx.com/mysite. Some of the navigate operations to /mysite/xxx are working, but other navigations to /mysite/yyy open the Safari window. Beside the <a href="xxx" /> links, are there other situations which can cause the web app to open the link in a separate Safari window ?

我不使用 target 属性.我所有的链接看起来像

I do not use target Attribute. All my links look like

<a ng-click="vm.replace('/mysite/xxx') class="navbar-brand">Contact</a>

...

replace(url:string) {
    this.$window.location.replace(url);
}

我还尝试了不同的变体(location.href = urllocation = url),结果都一样.也许问题与 IOS 9.2 相关,我确信在我几个月前创建的 Web 应用程序中使用了相同的构造.
目标页面的内容是否可能导致这种行为?从 /mysite/Home 导航到 /mysite/Media 工作,导航到 /mysite/EPG 打开 Safari 浏览器.
也许浏览器缓存中有问题?所以我清除了缓存,但结果相同.

I also tried the different variations (location.href = url, location = url) all with same result. Maybe the Problem is IOS 9.2 related, I am sure that the same construct was working in web apps I created some month ago.
Is it possible that the content of the target page is responsible for this behavior ? Navigating from /mysite/Home to to /mysite/Media works, navigating to /mysite/EPG opens the Safari browser.
Maybe something bad in the browser cache ? So I cleared the cache, but same result.

推荐答案

根据您的描述,听起来像是使用了target="_blank",这就是导致网页链接在一个新窗口.由于您的所有链接都使用 JavaScript,因此检查起来应该相对容易.

Based on your description, it sounds like target="_blank" is being used, which is what causes web links to open in a new window. As you're using JavaScript for all your links, this should be relatively easy to check.

这篇关于尽管避免了 HTML 'href' 链接,iOS 网络应用程序仍会打开 Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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