内部导航被拒绝:<allow-navigation not set> 在 iOS 上的 Cordova 中
Internal navigation rejected: <allow-navigation not set> in Cordova on iOS
我已经使用 Cordova 构建了一个 iOS 应用程序。该应用程序尝试加载网页,例如http://yourdomain.com/home in index.html. But, the page stays white blank with error in console "Internal navigation rejected - <allow-navigation> not set for url='http://yourdomain.com/home'".
我已经设置了<access origin="http://yourdomain.com/home" subdomains="true" />
,也尝试设置了<allow-navigation>
标签。但是页面保持空白。我还缺少其他东西吗?请指导。
在index.html中添加了以下meta标签后,"internal navigation error"消失了,但是页面还是一片空白。 :(
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script src: 'self' 'unsafe-inline' 'unsafe-eval'">
您必须将此行添加到您的 config.xml
<allow-navigation href="http://yourdomain.com/home" />
或者这个,如果你想允许导航到 yourdomain.com
上的所有 url
<allow-navigation href="http://yourdomain.com/*" />
不建议在您的基础网络视图中打开 url。使用cordova-plugin-inappbrowser 调用inappbrowser 打开外部url:
function open_outer_url(url){
if(window.cordova && window.cordova.InAppBrowser){
window.cordova.InAppBrowser.open(url, "_blank", 'location=no');
}else{
window.open(url,'_blank');
}
}
我遇到了这个问题,结果发现有两个 config.xml 文件。第一个在 Xcode 中,但您必须从文件系统编辑第二个。
AppName/config.xml
AppName/platforms/ios/AppName/config.xml
我加了
<allow-navigation href="*" />
对他们俩都有效。使用 6.3.0.
内部使用的方案,允许access/navigation即可:
<access origin="about:*" />
<allow-navigation href="about:" />
不建议使用
<access origin="*" />
<allow-navigation href="*" />
感谢指点。解决方案
<allow-navigation href="about:" />
导致科尔多瓦为我准备错误。我需要改用以下内容:
<allow-navigation href="about:*" />
我已经使用 Cordova 构建了一个 iOS 应用程序。该应用程序尝试加载网页,例如http://yourdomain.com/home in index.html. But, the page stays white blank with error in console "Internal navigation rejected - <allow-navigation> not set for url='http://yourdomain.com/home'".
我已经设置了<access origin="http://yourdomain.com/home" subdomains="true" />
,也尝试设置了<allow-navigation>
标签。但是页面保持空白。我还缺少其他东西吗?请指导。
在index.html中添加了以下meta标签后,"internal navigation error"消失了,但是页面还是一片空白。 :(
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script src: 'self' 'unsafe-inline' 'unsafe-eval'">
您必须将此行添加到您的 config.xml
<allow-navigation href="http://yourdomain.com/home" />
或者这个,如果你想允许导航到 yourdomain.com
上的所有 url<allow-navigation href="http://yourdomain.com/*" />
不建议在您的基础网络视图中打开 url。使用cordova-plugin-inappbrowser 调用inappbrowser 打开外部url:
function open_outer_url(url){
if(window.cordova && window.cordova.InAppBrowser){
window.cordova.InAppBrowser.open(url, "_blank", 'location=no');
}else{
window.open(url,'_blank');
}
}
我遇到了这个问题,结果发现有两个 config.xml 文件。第一个在 Xcode 中,但您必须从文件系统编辑第二个。
AppName/config.xml
AppName/platforms/ios/AppName/config.xml
我加了
<allow-navigation href="*" />
对他们俩都有效。使用 6.3.0.
内部使用的方案,允许access/navigation即可:
<access origin="about:*" />
<allow-navigation href="about:" />
不建议使用
<access origin="*" />
<allow-navigation href="*" />
感谢指点。解决方案
<allow-navigation href="about:" />
导致科尔多瓦为我准备错误。我需要改用以下内容:
<allow-navigation href="about:*" />