javascript - whatsapp://send?text= 不起作用

标签 javascript android whatsapp

我正在为 Android 开发一个混合应用程序。我添加了以下代码:

<a href="whatsapp://send data-text=mytext">Send message to WhatsApp</a>
<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>

但是,当我在手机上单击这些链接时,whatsapp 不会弹出。你能帮帮我吗?为什么不共享该消息?

提前致谢!

最佳答案

这是您应该使用的 URL:

https://api.whatsapp.com/send?phone=15551234567&text=I'm%20interested%20in%20your%20car%20for%20sale

在 JavaScript 中,您必须对文本进行编码,例如

var url='https://api.whatsapp.com/send'
var text='text can contain this char: &'
window.open(url + '?phone=2211227373&text=' encodeURIComponent(text))

关于javascript - whatsapp://send?text= 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48610523/

相关文章:

android - 将 String 从 Broadcastreceiver 传递给 MainActivity 并将其放入 Fragment

ios - 在 iOS 11 中的 whatsapp 上分享带标题的图片

swift - 无法在 swift 中共享 pdf(仅限 WhatsApp)

android - 如何设置像 WhatsApp 聊天而不是特定于移动设备的表情符号

javascript - 使用部分值/正则表达式进行切换?

android build/envsetup.sh addcompletions() "local T dir f"是什么意思?

android - adb shell dumpsys meminfo - 其输出的每个单元格的含义是什么?

javascript - 将代码从 jquery 转换为纯 javascript

javascript - CSS/JavaScript : How to count the number of displayed lines of an element?

javascript - "Some JS files act more like libraries - they [...] never manipulate QML component instances directly"- 中间立场?