2017-08-17 5 views
-1

Ich entwickle eine mobile App mit Apache Cordova. Dies ist eine sehr einfache App, die reaktionsschnelle Webseiten lädt. Momentan benutze ich das HTML-Tag, um die Seite zu laden, aber ich möchte den Cordova inappbrower für diesen Zweck verwenden.wie cordova inappbrowser plugin verwenden

Das ist mein www/index.html-Datei:

<!DOCTYPE html> 

<html> 
    <head> 
     <title>Title</title> 
    </head> 
    <body style="width: 100%;height: 100%;overflow: hidden;"> 
    <iframe style="width: 100%;height: 100%; border: none;" height="100%" src="http://www.mywebsite.com/"></iframe> 
     <script type="text/javascript" src="cordova.js"></script> 
     <script type="text/javascript" src="js/index.js"></script> 
    </body> 
</html> 

Das ist mein www/js/index.js Datei:

var app = { 

    initialize: function() { 
     document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); 
    }, 

    onDeviceReady: function() { 

     var networkState = navigator.network.connection.type; 

      var states = {}; 
      states[Connection.UNKNOWN] = 'Unknown connection'; 
      states[Connection.ETHERNET] = 'Ethernet connection'; 
      states[Connection.WIFI]  = 'WiFi connection'; 
      states[Connection.CELL_2G] = 'Cell 2G connection'; 
      states[Connection.CELL_3G] = 'Cell 3G connection'; 
      states[Connection.CELL_4G] = 'Cell 4G connection'; 
      states[Connection.NONE]  = 'No network connection'; 

      if ((states[networkState]) == states[Connection.NONE]) 
      { 
      window.location.href="noconnection.html"; 
      } else { 
      this.receivedEvent('deviceready'); 
      } 
    }, 

    // Update DOM on a Received Event 
    receivedEvent: function(id) { 
     var parentElement = document.getElementById(id); 
     var listeningElement = parentElement.querySelector('.listening'); 
     var receivedElement = parentElement.querySelector('.received'); 

     listeningElement.setAttribute('style', 'display:none;'); 
     receivedElement.setAttribute('style', 'display:block;'); 

     console.log('Received Event: ' + id); 
    } 
}; 

app.initialize(); 

Bitte um Hilfe. Ich habe den inappbrowser installiert, aber ich weiß nicht, wie man es benutzt.

Antwort

Verwandte Themen