den0
den0

Reputation: 186

Use cordova with existing webapp

I want to display dynamically generated html from my flask server in cordova. I searched up the answer and a lot of them recommend to do something like this in the index.html file.

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript">
     function onBodyLoad(){     
        document.addEventListener("deviceready", onDeviceReady, false);
     }
     function onDeviceReady(){
         window.location.href = <your_remote_url>
     }
}
</script>

Sadly this does not work and opens the page in the device's native browser. Is there another work around? Thanks in advance.

Upvotes: 1

Views: 145

Answers (2)

Hoon
Hoon

Reputation: 677

If you are feeling uncomfortable installing another plugin, please try iframe to display a webview within the app. Something like,

<div style="height: 100vh;">
  <iframe src="http://google.com" style="border: 0; height: 100vh; width:100%"></iframe>
</div>

Upvotes: 1

Atul Sharma
Atul Sharma

Reputation: 10645

Use cordova in app browser.

This will open the page in the app itself.

install

cordova plugin add https://github.com/apache/cordova-plugin-inappbrowser

how to use check..

https://github.com/apache/cordova-plugin-inappbrowser#sample

Upvotes: 1

Related Questions