我对 Cordova 很陌生,所以我可能不完全理解它的用途。让我从我总体上想要实现的目标开始。
我们有一个支持移动设备的 asp.net 网站,我基本上只是想用 iPhone 应用程序来包装它。当然,该站点在 IIS 服务器上运行,因此我只需要一个薄包装来启动该站点,并删除地址栏、导航等。据我了解,您可以使用 Cordova 混合方法来实现这一目标。
我按照教程进行操作,并在 xCode iPhone 模拟器中启动了该网站,结果正如我所愿。
我遇到的问题是网站内的超链接会在 Safari 浏览器中启动目标页面。从我所有的谷歌搜索来看,这似乎是大多数人遇到的相反问题。似乎大多数人都很难在应用程序内打开外部网站,这基本上将他们锁定在应用程序之外。我只是想在应用程序内我自己的网站上从 Page1 转到 Page2。
我能够用最简单的网站重现这个问题,所以我将发布相关部分。在此示例中,单击“Page 2”将在 Safari 中打开。
Asp.net 站点:
第1页.html
<html>
<a href="page2.html">Page 2</a>
</html>
第2页.html
<html>
Page 2
</html>
Cordova:
索引.html
<!DOCTYPE html>
<html>
<head>
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
</head>
<body>
Cordova site
</body>
<script>
window.location = "http://192.168.1.157:8081/Page1.html";
</script>
</html>
配置文件
<?xml version='1.0' encoding='utf-8'?>
<widget id="vsisolutions.testsite" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Test Site</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="http://192.168.1.157:8081/*" />
<allow-navigation href="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="ios" spec="~4.1.1" />
<plugin name="com.msopentech.authdialog" spec="~0.1.6" />
</widget>
谢谢您的帮助!