【发布时间】:2014-01-12 13:07:24
【问题描述】:
我正在构建一个phonegap + jquery 移动应用程序, 我正在尝试添加一个链接,该链接将使用 childbrowser phonegap 插件在子浏览器中打开网页。
我在 adobe phonegap 构建站点中看到,为了添加 childbrowser 插件,我只需要添加:
<gap:plugin name="com.phonegap.plugins.childbrowser" />
在 config.xml 文件中
我做到了,但它不起作用 我在这里错过了什么?
谢谢。
这是我的代码:
<!DOCTYPE HTML><html>
<head>
<meta name = "viewport" content = "user-scalable=no,width=device-width" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Test Page</title>
<link rel="stylesheet" href="js/jquery.mobile-1.4.0/demos/css/themes/default/jquery.mobile-1.4.0.min.css">
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script src="js/jquery.mobile-1.4.0/demos/js/jquery.js"></script>
<script src="js/jquery.mobile-1.4.0/demos/js/jquery.mobile-1.4.0.min.js"></script>
<script type="text/javascript" charset="utf-8">
function init(){
document.addEventListener("deviceready", ready, true);
}
function ready() {
console.log("phonegap is ready !");
}
</script></head> <body onload="init();">
<div data-role="page" id="home">
<div data-role="content">
<a href="#" onClick="window.plugins.childBrowser.showWebPage('http://www.google.com')">Open link in child browser !</a>
</div>
</div>
这是我的 config.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "il.co.app.chazak"
versionCode="1.0"
version = "1.0">
<preference name="phonegap-version" value="3.1.0" />
<name>chazak</name>
<description>Chazak book librery</description>
<author href="http://www.shtibel.com" email="dushy@shtibel.com">Dushy</author>
<preference name="phonegap-version" value="2.9.0" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="true" />
<preference name="ios-statusbarstyle" value="default" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="true" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-maxSdkVersion" value="17" />
<preference name="android-installLocation" value="auto" />
<preference name="splash-screen-duration" value="0" />
<preference name="load-url-timeout" value="0" />
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<icon src="icon/iphone/Icon.png" gap:platform="ios" width="57" height="57" />
<icon src="icon/iphone/Icon-72.png" gap:platform="ios" width="72" height="72" />
<icon src="icon/iphone/Icon-2x.png" gap:platform="ios" width="114" height="114" />
<icon src="icon/iphone/Icon-72-2x.png" gap:platform="ios" width="144" height="144" />
<icon src="icon/android/ldpi.png" gap:platform="android" gap:density="ldpi" />
<icon src="icon/android/mdpi.png" gap:platform="android" gap:density="mdpi" />
<icon src="icon/android/hdpi.png" gap:platform="android" gap:density="hdpi" />
<icon src="icon/android/xhdpi.png" gap:platform="android" gap:density="xhdpi" />
<gap:splash src="splash/iphone/Default.png" width="320" height="480" />
<gap:splash src="splash/iphone/Default-2x.png" width="640" height="960" />
<gap:splash src="splash/iphone/Default-568h2x.png" width="640" height="1136" />
<gap:splash src="splash/iphone/Default-Portrait.png" width="768" height="1024 " />
<gap:splash src="splash/android/ldpi.png" gap:platform="android" gap:density="ldpi" />
<gap:splash src="splash/android/mdpi.png" gap:platform="android" gap:density="mdpi" />
<gap:splash src="splash/android/hdpi.png" gap:platform="android" gap:density="hdpi" />
<gap:plugin name="com.phonegap.plugins.childbrowser" version="4.2.1" />
<access origin="*" />
<access uri="*" subdomains="true" />
</widget>
【问题讨论】:
-
为什么不用inAppBrowser?它很久以前就取代了 childbrowser
-
你能指导我看一个示例代码吗?
-
inAppBrowser 有一个选项来显示应用程序的页眉和页脚,它可以显示 PDF 文件吗?
-
我尝试使用 inAppBrowser,但在 adobe phonegap build 上出现此错误:不支持插件:org.apache.cordova.inappbrowser
-
现在可以了,但是如何显示 App 页眉/页脚?
标签: cordova phonegap-plugins phonegap-build childbrowser