【问题标题】:How can my Phonegap-App open a Link in the Android Browser?我的 Phonegap-App 如何在 Android 浏览器中打开链接?
【发布时间】:2014-03-27 19:07:06
【问题描述】:

我的 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>

我该怎么做。请发布一些示例。


仍然在应用程序内打开。 我的配置:

<?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>

我做错了什么?

【问题讨论】:

    标签: android html cordova phonegap-build


    【解决方案1】:
    <a onclick="openThatLink()">store.spyfly.tk</a>
    
    function openThatLink() {
                window.open('http://store.spyfly.tk', '_system', 'location=yes');
    }
    

    【讨论】:

      【解决方案2】:

      试试这个:-

      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

      【讨论】:

      • 如果你想使用原生浏览器,你必须使用_system而不是_blank
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-12
      • 2014-04-24
      • 1970-01-01
      • 2012-02-21
      相关资源
      最近更新 更多