我的Phonegap-App如何在Android浏览器中打开链接?

时间:2014-03-27 19:07:07

标签: android html5 cordova phonegap-build

我的Phonegap-App如何在Android浏览器中打开链接?我尝试了很多代码,但它们没有用。

这是我的实际代码: <a href="http://store.spyfly.tk" target="_system">store.spyfly.tk</a>

和config.xml

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<?xml-stylesheet href="" type="text/xsl"?>

<!DOCTYPE tag [
    <!ELEMENT tag (#PCDATA)>
]>
 <tag>
    <widget id="tk.spyfly.store.MANOS_VPlan" version="0.1.0">
        <name>MANOS-VPlan</name>
        <description>
            Vertretungspläne für das Martin-Andersen-Nexö-Gymnasium.
        </description>
        <author email="spyfly@pvpcrafter.tk" href="http://store.spyfly.tk">
            spyfly software
        </author>
        <content src="index.html" />
        <access origin="*" />
        <preference name="Fullscreen" value="true" />
        <preference name="WebViewBounce" value="true" />
    </widget>
</tag>

我该怎么办?请发布一些例子。


仍在App内打开。 我的配置:

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<?xml-stylesheet href="" type="text/xsl"?>

<!DOCTYPE tag [
    <!ELEMENT tag (#PCDATA)>
]>
 <tag>
    <widget id="tk.spyfly.store.MANOS_VPlan" version="0.1.0">
        <name>MANOS-VPlan</name>
        <description>
            Vertretungspläne für das Martin-Andersen-Nexö-Gymnasium.
        </description>
        <author email="spyfly@pvpcrafter.tk" href="http://store.spyfly.tk">
            spyfly software
        </author>
        <content src="index.html" />
        <access origin="*" />
        <preference name="Fullscreen" value="true" />
        <preference name="WebViewBounce" value="true" />
    </widget>
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<access origin="*" browserOnly="true" />
</tag>

我的index.xml

<!DOCTYPE html>
<html>

<head>
    <title>MANOS-VPlan</title>

    <meta charset="ISO-8859-1">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="keywords" content="">

    <link href="style.css" type="text/css" rel="stylesheet">

</head>

<body>


<a onclick="openThatLink()">store.spyfly.tk</a>


<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">
function openThatLink() {
            window.open('http://store.spyfly.tk', '_blank', 'location=yes');

}
    </script>
</body>
</html>

我错了什么?

2 个答案:

答案 0 :(得分:1)

<a onclick="openThatLink()">store.spyfly.tk</a>

function openThatLink() {
            window.open('http://store.spyfly.tk', '_system', 'location=yes');
}

答案 1 :(得分:0)

试试这个: -

window.open('http://store.spyfly.tk', '_blank', 'location=yes');

在config.xml中包括:

<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<access origin="*" browserOnly="true" />

InAppBrowser是一个Web浏览器,在调用window.open时显示在应用程序中。

参考Phonegap Doc