Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android cordova在系统浏览器中打开外部网站,而不是在应用程序中打开_Android_Cordova - Fatal编程技术网

Android cordova在系统浏览器中打开外部网站,而不是在应用程序中打开

Android cordova在系统浏览器中打开外部网站,而不是在应用程序中打开,android,cordova,Android,Cordova,Cordova不在it应用程序中打开外部网站。当它启动时,它将在系统浏览器中打开。 这是我的密码 资料来源: index.html <!DOCTYPE html> <html> <head> <title>Hello World</title> <script type="text/javascript" src="cordova.js"></script>

Cordova不在it应用程序中打开外部网站。当它启动时,它将在系统浏览器中打开。 这是我的密码

资料来源:

index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Hello World</title>
        <script type="text/javascript" src="cordova.js"></script>
        <script>

            document.addEventListener("deviceready", onDeviceReady, false); 

            function checkConnection() {
                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';

                return networkState;
            }            

            function onDeviceReady() {
                var networkState = checkConnection();
                alert(networkState);
                if (networkState == Connection.NONE) {
                    navigator.notification.alert('This app requires an internet connection'); 
                } else {
                    window.location="http://www.google.co.in";
                }
            }

        </script>
    </head>
    <body>

    </body>
</html>

你好,世界
文件。添加的监听器(“deviceready”,OnDeviceraddy,false);
函数checkConnection(){
var networkState=navigator.network.connection.type;
变量状态={};
状态[Connection.UNKNOWN]=“未知连接”;
状态[Connection.ETHERNET]=“以太网连接”;
状态[Connection.WIFI]=“WIFI连接”;
状态[Connection.CELL_2G]=“CELL 2G Connection”;
状态[Connection.CELL_3G]=“CELL 3G Connection”;
状态[Connection.CELL_4G]=“CELL 4G Connection”;
状态[Connection.NONE]=“无网络连接”;
返回网络状态;
}            
函数ondevicerady(){
var networkState=checkConnection();
警报(网络状态);
if(networkState==Connection.NONE){
navigator.notification.alert(“此应用程序需要internet连接”);
}否则{
window.location=”http://www.google.co.in";
}
}
config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Dola</name>
    <description>
        Dola
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Dola Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" version="1" />
    <access origin="http://www.google.co.in" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>

</widget>

多拉
多拉
多拉队

我到处搜索,所有的文档,但仍然无法找出问题所在。请帮助我。

最简单的方法是在
config.xml
中编辑您的
src
标记,指向您的外部网站。这不需要安装InAppBrowser插件 内容
src=”http://example.com“

否则,请安装InAppBrowser并按以下方式加载外部网站,以避免工具栏或缩放功能

var ref = window.open('https://example.com/', '_blank', 'location=no,toolbar=no,zoom=no');

使用inAppBrowser插件打开外部website@Rudrakshya,你的问题解决了吗?没有,还是没有解决。我添加了一个应用程序浏览器。但它有url栏。我不想那样。我希望我的应用程序中的站点看起来像本地站点。在config.xml中编辑src标记对我不起作用。网站仍在系统浏览器中打开。