Phonegap inappbrowser 不工作
Phonegap inappbrowser not working
我对插件 cordova-plugin-inappbrowser 进行了简单测试,但它不起作用,请帮忙。
我做了什么:
1. phonegap 创建 phonegap-default
2. phonegap插件添加cordova-plugin-inappbrowser --save
3. 将此行添加到 www/index.html 底部 "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 服务
- 打开 phonegap 开发应用程序(在 iOS 9.2.1 中),连接到 phonegap 服务器然后点击测试 link。什么都没发生。
我的 Phonegap 版本是 5.4.1。提前致谢。
我认为你应该添加:
<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 插件:
我对插件 cordova-plugin-inappbrowser 进行了简单测试,但它不起作用,请帮忙。
我做了什么:
1. phonegap 创建 phonegap-default
2. phonegap插件添加cordova-plugin-inappbrowser --save
3. 将此行添加到 www/index.html 底部 "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 服务
- 打开 phonegap 开发应用程序(在 iOS 9.2.1 中),连接到 phonegap 服务器然后点击测试 link。什么都没发生。
我的 Phonegap 版本是 5.4.1。提前致谢。
我认为你应该添加:
<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 插件: