일전에 모바일웹에서 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);
}

#자바스크립트 #모바일웹 #SMS #a태그 #smsbody #문자대입 #문자전송 #a태그활용 #모바일a태그 #php #넷프로 #netpro


+ Recent posts