user2990084 user2990084 - 4 months ago 61
Android Question

Open url in webview - phonegap

I would like to know how can I open an url in the app context of embed webview. Currently this demo will open a new tab in external browser, so, not what I am expected. I am using just for testing.

Summary, I am looking for a functional demo.

<?xml version="1.0" encoding="UTF-8"?>

<!-- config.xml reference: -->
<widget xmlns = ""
xmlns:gap = ""
xmlns:android = ""
id = ""
version = "1.0.0">

<preference name="stay-in-webview" value="true" />

<access origin="*" browserOnly="true" subdomains="true" />

<content src="index.html" />

<allow-navigation href="*" />

<gap:plugin name="cordova-plugin-whitelist" source="npm" version="~1" />
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.splashscreen" />

<preference name="phonegap-version" value="cli-5.4.1" />
<preference name="permissions" value="none"/>
<preference name="target-device" value="universal"/>
<preference name="fullscreen" value="true"/>


<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
window.location.href = '';
<script type="text/javascript" src="cordova.js"></script>

Complete xml file:


try :'', '_self ', 'location=yes');

instead of :

window.location.href = '';

This will use the InAppBrowser, and use _self as target.