开发者

How to initiate/send SMS from a HTML5 webpage using devices native functions?

I am wondering how can I open the send SMS application by using a web contr开发者_运维百科ol of a HTML5 page on Android and iPhone. I want to use the device native SMS sending app, with a prepopulated value from the web.


Further to other answers I can confirm that smsto:555:bodytext does not work on an iPhone running iOS5.

What does work (and I've tested it) on Android is the format:

sms:444?body=hello

Example:

<a href="sms:444?body=hello">Tap to say hello!</a>

On iPhone the ?body=hello will prevent it working at all, and you should use just sms:555 instead.

sms:555

Example

<a href="sms:444">Tap to text us!</a>


I have tested the below and it works:

Using HTML Anchor tag:

<a href="sms:111?body=SUBSCRIBE">Subscribe</a>

Using JavaScript:

window.open('sms:111?body=SUBSCRIBE', '_self');


With Android 3.0 SDK Google has started exposing API in HTML5 for device access. An example is listed here. It may not be enough for what you seek to do.

I dont know enough about iphone to advise either way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜