科尔多瓦InAppBrowser.open。链接在 safari 上打开,而不是在应用程序内打开
Cordova InAppBrowser.open. Links are opening on safari instead of opening inside the app
我的小型 cordova 应用程序非常简单,在检查是否存在连接后,打开网站的 url(例如 http://www.example.com)。
我希望所有 urls/websites 都显示在应用程序中。
主要问题是 iOS 只打开应用程序的第一页,其他任何 link 即 clicked/touched 在 safari 浏览器中打开。
在config.xml
我已经设置
<access origin="*" />
在 index.js 我添加了
onDeviceReady: function() {
window.open = cordova.InAppBrowser.open;
if (navigator.connection.type == Connection.NONE) {
navigator.notification.alert('An internet connection is required to continue');
} else {
setTimeout(function(){window.open('http://www.example.com', '_self', 'location=no')} , 3000);
}
},
我已经尝试在没有 inappbrowser 的情况下使用我的代码(没有前面代码中的第二行,也没有插件)。
我已经删除并重新添加了平台。
我重新创建了整个应用程序。
我检查了应用程序(cordova 平台检查)。
在 anrdoid 和 blackberry 上,它可以根据我的需要使用应用程序内的导航(有和没有 inappbrowser)!
科尔多瓦 6.1.1
mac 迷你 - osx el capitan 10.11.5
我认为这是由于未正确设置 config.xml 中的 allow-intent href 属性造成的,如下所述:
https://issues.apache.org/jira/browse/CB-10859
在您的 config.xml 文件中查找此声明:
<allow-intent href="*" />
并将其替换为更具体的意图津贴,例如:
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
这应该涵盖了大多数意图。
我的小型 cordova 应用程序非常简单,在检查是否存在连接后,打开网站的 url(例如 http://www.example.com)。 我希望所有 urls/websites 都显示在应用程序中。
主要问题是 iOS 只打开应用程序的第一页,其他任何 link 即 clicked/touched 在 safari 浏览器中打开。
在config.xml 我已经设置
<access origin="*" />
在 index.js 我添加了
onDeviceReady: function() {
window.open = cordova.InAppBrowser.open;
if (navigator.connection.type == Connection.NONE) {
navigator.notification.alert('An internet connection is required to continue');
} else {
setTimeout(function(){window.open('http://www.example.com', '_self', 'location=no')} , 3000);
}
},
我已经尝试在没有 inappbrowser 的情况下使用我的代码(没有前面代码中的第二行,也没有插件)。 我已经删除并重新添加了平台。 我重新创建了整个应用程序。 我检查了应用程序(cordova 平台检查)。
在 anrdoid 和 blackberry 上,它可以根据我的需要使用应用程序内的导航(有和没有 inappbrowser)!
科尔多瓦 6.1.1 mac 迷你 - osx el capitan 10.11.5
我认为这是由于未正确设置 config.xml 中的 allow-intent href 属性造成的,如下所述:
https://issues.apache.org/jira/browse/CB-10859
在您的 config.xml 文件中查找此声明:
<allow-intent href="*" />
并将其替换为更具体的意图津贴,例如:
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
这应该涵盖了大多数意图。