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

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

问题描述



我读过的所有东西似乎都表明短信:18005555555?body = bodyTextHere



应该可以工作,但在iPhone上,这不起作用。如果我将?body = bodyTextHere取出,并且只使用sms:phonenumber,它就可以。



我已经看到几个QR码通过Safari链接执行此操作的情况。他们如何能够预先填充正文文本?

解决方案

事实证明,这是100%可能的,虽然有点hacky 。

如果你想让它在Android上运行,你需要使用下面的格式:

< a href =sms:/ *电话号码在这里* /?body = / *正文在这里* />链接< / a>



如果您希望它在iOS上运行,您需要:

< a href =sms:/ *电话号码* /; body = / * body text here / /> Link< / a>



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



更新:



显然iOS8不得不去改变我们的东西,所以感谢其他一些评论者/响应者,iOS有一种新风格:


< a href =sms:/ *此处的电话号码* /& body = / *此处的正文文本* />连结< / a>



(电话号码是可选的)


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

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

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

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

解决方案

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

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

<a href="sms:/* phone number here */?body=/* body text here */">Link</a>

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

<a href="sms:/* phone number here */;body=/* body text here */">Link</a>

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)

UPDATE:

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:/* phone number here */&body=/* body text here */">Link</a>

(phone number is optional)

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

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