我对插件cordova-plugin-inappbrowser进行了一个简单的测试,它只是不起作用,请帮忙。
我做了什么:
1. phonegap创建phonegap-default
2. phonegap插件添加cordova-plugin-inappbrowser --save
3.将此行添加到“app”div:
<a href="var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');"><h1>Test</h1></a>
index.html如下:
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>PhoneGap</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<a href="var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');"><h1>Test</h1></a>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
我的Phonegap版本是5.4.1。提前谢谢。
答案 0 :(得分:0)
我认为你应该补充:
<access origin="http://apache.org" subdomains="true" />
在config.xml中 也许添加
也是必要的<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
有关详细信息,请访问: https://cordova.apache.org/docs/en/3.0.0/cordova/inappbrowser/inappbrowser.html
要在Android上使用此插件,您还应添加cordova-plugin-whitelist插件: