Phonegap iframe外部链接 - 发送到whatsapp

时间:2016-01-17 16:54:57

标签: android cordova iframe whatsapp

我在www.mywebsite.com上有whatsapp链接:

<a href="intent://send/+550112345678#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end">whatsapp link</a>

我在智能手机浏览器中运行时没关系。但是,不能在我的phonegap应用程序(iframe)中运行:

<!DOCTYPE HTML>
<html>
    <head>
        <title>My Phonegap application</title>
        <meta name="viewport" content="width=device-width,initial-scale=1"/>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="css/styles.css" />
        <script type="text/javascript" src="cordova.js"></script>

        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
        <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    </head>

    <script type="text/javascript" charset="utf-8">
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        $( "#content").html('<iframe src="http://www.mywebsite.com" frameborder="0"></iframe>');
    }
    </script>
    </head>
    <body>
        <div data-role="page" id="main">
            <div id="content" data-role="content"></div>
        </div>
    </body>
</html>

请帮帮我!

1 个答案:

答案 0 :(得分:0)

我的解决方案:

在我的框架页面中添加:

<button onclick="return open_a_window('+5511012345678');">whatsapp</button>

<script language="javascript">

function open_a_window(number)
{
    window.open("close.php?number="+number);
    return false;   
}
</script>

我创建了close.php:

<?php
    $id = $_GET["number"];
    header("location: intent://send/$id#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end");
?>

<script language="javascript">

    function quitBox(cmd)
    {   
        if (cmd=='quit')
        {
            open(location, '_self').close();
        }   
        return false;   
    }

    quitBox('quit');

</script>