JAVA SCRIPT
function goMobilePage(mobile_url, go_flag, msg){
var userAgent = window.navigator.userAgent;
var mobileKeyWords = new Array();
var is_mobile = false;
mobileKeyWords.push("iPhone");
mobileKeyWords.push("iPod");
mobileKeyWords.push("BlackBerry");
mobileKeyWords.push("Android");
mobileKeyWords.push("Windows CE");
mobileKeyWords.push("LG");
mobileKeyWords.push("MOT");
mobileKeyWords.push("SAMSUNG");
mobileKeyWords.push("SonyEricsson");
//유효성 체크
if(!userAgent){
window.alert("사용하시는 브라우저의 정보를 얻을 수 없습니다.");
return;
}
//웹 브라우저 정보의 문자들을 대문자로 변환
userAgent = userAgent.toUpperCase();
//반복문을 수행하여 모바일 키워드에 매칭되는것이 존재하는지 검사
for(var i=0 ; i<mobileKeyWords.length ; i++){
mobileKeyWords[i] = mobileKeyWords[i].toUpperCase();
if(userAgent.indexOf(mobileKeyWords[i]) != -1)
is_mobile = true;
}
//모바일 페이지가 맞고, go_flag 값이 true이면 지정된 모바일 페이지로 이동
if(is_mobile == true && go_flag == true){
//보여줄 메시지가 존재하는 경우만 Alert 수행
if(msg && msg != "") window.alert(msg);
//모바일 페이지로 이동
window.location.href = mobile_url;
}
}
//사용 브라우저가 Internet Explor 인지 확인
var isIE = false;
if ( (navigator.appName == 'Netscape' && navigator.userAgent.search('Trident') != -1) || (agent.indexOf("msie") != -1) ) {
isIE = true;
}
JAVA
String userAgent = request.getHeader("user-agent");
boolean isIE = (userAgent.toUpperCase().indexOf("TRIDENT") > -1 || userAgent.toUpperCase().indexOf("IE") > -1);