Cordova在Safari中而不是在应用程序中打开startPage

时间:2017-07-31 15:22:34

标签: ios cordova

我创建了一个新的Cordova项目并将我的URL放在AppDelegate.m中:

// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
// If necessary, uncomment the line below to override it.
self.viewController.startPage = @"http://mySite/";

当我在模拟器中启动应用程序时,它会启动,然后在Safari中而不是在应用程序中打开我的网址。

为什么会这样?

谢谢:)

2 个答案:

答案 0 :(得分:1)

我错过的是添加这一行:

<allow-navigation href="*" />

位于config.xml文件的<widget>标记下。

答案 1 :(得分:0)

对不起,我有点不清楚你想要达到的目标: 尝试访问您的应用程序中第一个位于Cordova项目的www文件夹中的HTML页面,或尝试访问不属于您的应用程序但托管在Web服务器上的网站。

对于后来的情况,在您的应用中运行外部代码是危险的,这就是原因。要加载网站,使其看起来好像在您的应用中,您可以使用应用内浏览器插件: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/

对于前一种情况,如果您在www文件夹中的启动HTML文件被称为“index.html”,那么您在config.xml文件中所需要的只是<content src="index.html" />

相关问题