javascript - 使用 cordova 社交共享插件发送带有变量的短信

标签 javascript android html cordova

我正在使用social share plugin Cordova 将短信分享到特定号码。

<a
    class = "lft"
    onclick="window.plugins.socialsharing.shareViaSMS('My cool message', 7767051447, function(msg) {console.log('ok: ' + msg)}, function(msg) {alert('error: ' + msg)})">
    <img src="sms.png"  alt="info" height="8%" align="middle">
</a>

它应该传递一个包含电话号码的变量phone_no,而不是传递号码。我如何实现这一目标?

最佳答案

如果您确定应该传递变量而不是数字。然后你就可以这样做。

<script>
var phone_no="7767051447";
function sendN()
 {
 window.plugins.socialsharing.shareViaSMS('My cool message', phone_no, function(msg) {console.log('ok: ' + msg)}, function(msg) {alert('error: ' + msg)});

 }
</script>

并在该 anchor 标记的 onclick 中调用 sendN() 。 顺便说一句,在您的代码中,您应该将您的号码放在引号内。它会起作用的。

关于javascript - 使用 cordova 社交共享插件发送带有变量的短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39666454/

相关文章:

javascript - 在 Meteor 中 {{#each}} 创建的表中的 DIV 上查找(即设置 CSS)的最佳方法?

android - 在 ListView 中显示来自游标的列

android - 如何解决 Android Studio 找不到项目 list 文件的错误?

android - 如何根据api级别应用主题

html - CSS: max-height: 剩余空间

javascript - 为现有代码添加延迟?

php - 使用 PHP 将换行符传递到文本区域

javascript - jquery css 背景颜色不起作用

javascript - 删除嵌入的元素

javascript - Angular.ui 警报不会关闭