如何通过 html 链接预填充短信正文 [英] How to pre-populate the sms body text via an html link

查看:24
本文介绍了如何通过 html 链接预填充短信正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用html链接打开带有预填充正文的短信应用?

How to use an html link to open the sms app with a pre-filled body?

我所读的一切似乎都表明 sms:18005555555?body=bodyTextHere

Everything I have read seems to indicate that sms:18005555555?body=bodyTextHere

应该可以,但在 iPhone 上,这行不通.如果我去掉 ?body=bodyTextHere,然后只使用 sms:phonenumber,它就可以工作.

Should work, but on the iPhone, this doesn't work. If I take out the ?body=bodyTextHere, and just use sms:phonenumber, it works.

我见过几个例子,其中 QR 码通过 safari 链接执行此操作.他们如何能够预先填充正文?

I have seen several instances where QR codes do this through a safari link. How are they able to pre-populate the body text?

推荐答案

事实证明这是 100% 可能的,尽管有点老套.

It turns out this is 100% possible, though a little hacky.

如果你想让它在 Android 上运行,你需要使用这种格式:

If you want it to work on Android you need to use this format:

<a href="sms:/* 此处为电话号码 */?body=/* 此处为正文 */">Link</a>

如果你想让它在 iOS 上运行,你需要这个:

If you want it to work on iOS, you need this:

<a href="sms:/* 此处为电话号码 */;body=/* 此处为正文 */">Link</a>

现场演示:http://bradorego.com/test/sms.html(注意电话和?body" 和 "Phone and ;body" 应自动填充 to: 字段和正文文本.查看源以获取更多信息)

Live demo here: http://bradorego.com/test/sms.html (note the "Phone and ?body" and "Phone and ;body" should autofill both the to: field and the body text. View the source for more info)

更新:

显然,iOS8 不得不去改变我们的事情,所以感谢其他一些评论者/回复者,iOS 有了新的风格:

Apparently iOS8 had to go and change things on us, so thanks to some of the other commenters/responders, there's a new style for iOS:

<a href="sms:/* 此处为电话号码 */&body=/* 此处为正文 */">Link</a>

(电话号码是可选的)

这篇关于如何通过 html 链接预填充短信正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆