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?
The short answer is, adding hyperlinks into SMS text messages isn't possible. Hyperlinks can only be used in emails and on your business website.
SMS does not support HTML. Do not use href tags in the link address. For example, <a href="www.example.com">link text</a> is not supported.
Approach: Using <a> href attribute: Enter the phone number in place of the URL and add sms: before it to make an SMS link. Add the text between the tags that will appear as the clickable link.
With a bit of HTML, it's possible to create a hyperlink that sends an SMS message. You can even prepopulate the SMS body text via the link! Here's how. Links need no introduction. They’re everywhere on the internet, literally. In HTML, links are defined with the <a> tag.
But few people know that you can launch the SMS app on your website visitors’ phones with an HTML link. This is perfect for starting conversations with your customers, especially when you consider that you can add a Click to Text link to more than just text. We’re confident you’ll love how easy it is to text your customers with SimpleTexting.
Add Click to Text to the following places, or anywhere you may include an HTML link: It only take a couple of minutes to create an HTML link that sends a text. And you can even pre-populate the SMS body text via the HTML link. Here’s how: 1. Write Your Link Text This is the text that your website visitors will read and click on.
While HTML anchor tags are most often used to link pages, there are also other possibilities including launching an email client and the Messages app on mobile devices. This article explores sending custom SMS messages using simple HTML links.
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)
I know this is an old thread but stumbled upon it and found that some parts are no longer relevant.
I've found that if you want to just per-populate the text without adding a phone number, you can do the following:
sms:?&body=/* message body here */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With