일전에 모바일웹에서 a 태그를 활용한 문자 메시지 내용을 입력하는 방법을 포스트 한적 있는데
이번엔 그걸 좀더 심화시켜 함수로 만들어 쓰는 방법이다
출처 : https://stackoverflow.com/questions/19387614/window-location-href-for-sms-messaging-platform-compatability
var ua = navigator.userAgent.toLowerCase();
var url;
if (ua.indexOf("iphone") > -1 || ua.indexOf("ipad") > -1)
url = "sms:;body=test";
else
url = "sms:?body=test";
//window.location.href = url;
window.open (url);
stackoverflow 에서 찾은 소스인데 아래와 같이 함수로 만들어 사용하면 되겠다.
// 전송할 번호만 대입하면 된다. function sms_msg( number ){ var ua = navigator.userAgent.toLowerCase(); var url; if (ua.indexOf("iphone") > -1 || ua.indexOf("ipad") > -1) url = "sms:" + number + ";body=test"; else url = "sms:" + number + "?body=test"; //window.location.href = url; window.open (url); }
'Programming > JAVAScript' 카테고리의 다른 글
모바일웹에서 a 태그를 활용한 문자 메시지 내용 입력하기 (0) | 2017.10.15 |
---|---|
number_format 구현 (0) | 2015.01.13 |
0단위 자리 절사 함수 (0) | 2015.01.13 |
자바스크립트로 외부 이미지 사이즈 알아내기 (0) | 2015.01.09 |
날짜 및 시간 계산 (0) | 2015.01.09 |