使用inappbrowser您可以創建一個命令科爾多瓦的移動app.Simply安裝inappbrowser插件裏面你的網站的網頁視圖。
cordova plugin add cordova-plugin-inappbrowser --save
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
// app.receivedEvent('deviceready');
var element=document.getElementById('status-message');
console.log(element);
var ref = cordova.InAppBrowser.open('url', '_blank', 'location=no');
ref.addEventListener('loadstart', function(event) {
element.innerHTML="Please Wait App is loading....." ;
});
}
};
另一個建議是不加載你的網站爲主要出發文件。由於phonegap需要大量文件,因此首頁顯示可能需要很長時間。我會使用正常的本地index.html和它在deviceready上,加載您的網站與top.location.href = ...我所做的是一個加載程序頁面上啓動一個進度條,使用Ajax加載每個JS和CSS文件的網站需要。從那時起,所有內容都被緩存,所有頁面加載速度都很快。 –