我正在构建一个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>
答案 0 :(得分:1)
您必须在childbrowser.js
之后加入cordova.js
脚本:
<script type="text/javascript" charset="utf-8" src="childbrowser.js"></script>