【问题标题】:Showing a web page in a phonegap app - android在 phonegap 应用程序中显示网页 - android
【发布时间】:2019-11-16 20:35:37
【问题描述】:

尝试在 phonegap 应用中显示现有网页。这似乎是 2014 年的一个大话题,但现在这些答案似乎都不适用。

这是我在 index.html 中所做的。它适用于网络浏览器,但不适用于应用程序。有没有人解决这个问题?也许我在某处缺少权限?

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
        <title>Blank App</title>
    </head>
    <body onload="window.location.href='http://www.google.com'">
        <script type="text/javascript" src="cordova.js"></script>
        <p>hello</p>
    </body>
</html>

这也适用于浏览器,但不适用于 phonegap...

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Refresh" content="0; url=https://www.google.com" />        
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
        <title>Broken</title>
    </head>
    <body>
        <script type="text/javascript" src="cordova.js"></script>
    </body>
</html>

这也行不通……

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
        <title>Broken</title>
    </head>
    <body>
        <a href="" onclick="window.location.href='https://google.com'">HELLO</a>
        <script type="text/javascript" src="cordova.js"></script>
    </body>
</html>

【问题讨论】:

    标签: android html webview phonegap-desktop-app


    【解决方案1】:

    就是这样,我花了 100 美元来加班。我希望它可以避免一些人头疼!

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
            <title>Broken</title>
        </head>
        <body>
            <script type="text/javascript" src="cordova.js"></script>
            <script>
            document.addEventListener("deviceready", onDeviceReady, false);
            function onDeviceReady() {
                var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=no');
            }
            </script>
        </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      • 2018-09-24
      • 1970-01-01
      相关资源
      最近更新 更多