Cordova - 如何重定向到另一个页面。始终在新的外部浏览器中打开

时间:2016-12-25 13:15:57

标签: android cordova web phonegap-plugins phonegap-build

在我的index.html文件中,我有 window.location ='http:....',我可以将应用程序发布到android。

在Android手机上运行应用程序时,我询问浏览器我应该用Chrome浏览器打开它。

显然,我的目的是将外部应用程序作为phonegap应用程序运行。

这不是posbbile吗?

本指南还建议这样做:

http://antonylees.blogspot.se/2013/02/launch-website-as-mobile-app-using.html

的index.html

<!DOCTYPE html>
<html>
<head>
    <!--
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
    -->
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
</head>
<body>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">

        document.addEventListener("deviceready", function() {
            window.location = "http://81.224.20.10:8080";
        }, false);
    </script>
</body>
</html>

config.xml中

<?xml version='1.0' encoding='utf-8'?>
<widget id="mycmpany.tv" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>mycmpany.tv</name>
    <description>
        Watch Tv from all over the world, anywhere, everywhere.
    </description>
    <author email="mo@mycmpany.com" href="http://mycmpany.tv">
        mycmpany.tv team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />

    <access origin="http://83.254.80.10:8080" subdomains="true"/>

    <access origin="*" />
    <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">
        <preference name="android-minSdkVersion" value="18"/>
        <preference name="android-targetSdkVersion" value="23"/>

        <allow-intent href="market:*" />
    </platform>

    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>

</widget>

我缺少什么?

注意,我尝试过使用cordova.InAppBrowser,但不幸的是你会得到地址栏和所有内容,但仍然不是一个很好的解决方案。

0 个答案:

没有答案