<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
<script type="text/javascript">

// InternetVersion
function getInternetVersion(ver) {
var rv = -1; // Return value assumes failure.
var ua = navigator.userAgent;
var re = null;
if(ver == "MSIE"){
re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
}else{
re = new RegExp(ver+"/([0-9]{1,}[\.0-9]{0,})");
}
if (re.exec(ua) != null){
rv = parseFloat(RegExp.$1);
}
return rv;
}

//브라우저 종류 및 버전확인
function browserCheck(){
var ver = 0; // 브라우저 버전정보
if(navigator.appName.charAt(0) == "N"){
if(navigator.userAgent.indexOf("Chrome") != -1){
ver = getInternetVersion("Chrome");
alert("Chrome"+ver+"입니다.");
}else if(navigator.userAgent.indexOf("Firefox") != -1){
ver = getInternetVersion("Firefox");
alert("Firefox"+ver+"입니다.");
}else if(navigator.userAgent.indexOf("Safari") != -1){
ver = getInternetVersion("Safari");
alert("Safari"+ver+"입니다.");
}
}else if(navigator.appName.charAt(0) == "M"){
ver = getInternetVersion("MSIE");
alert("MSIE"+ver+"입니다.");
}
}
</script>
</head>
<body>
<input type="button" value="브라우저판별" onclick="browserCheck();">
</body>
</html>

========================================================================================

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<script>
var Station = {
check : function (type, checkStr, checkPoint)
{
var name = "ETC";
for ( var list in checkPoint )
{
if (checkStr.indexOf(list) != -1)
{
name = checkPoint[list];
}
}
escape("this." + type + " = function () { return name }") ;
return name;
},
os : function ()
{
var checkStr = navigator.platform.toLowerCase();
var checkPoint =
{
"win" : "WINDOW", "mac" : "MAC", "unix" : "UNIX", "linux" : "LINUX"
}
return this.check("os", checkStr, checkPoint );
},
browser : function ()
{
var checkStr = navigator.userAgent.toLowerCase();
var checkPoint =
{
"msie 6" : "IE6" , "msie 7" : "IE7", "firefox" : "FF", "navigator" : "NETSCAPE", "opera" : "OPERA"
}
return this.check("browser", checkStr, checkPoint);

}
}
document.write("OS : " + Station.os() + "<br/>");
document.write("Browser : " + Station.browser() + "<br/>");
</script>
</body>
</html>

2011/12/06 11:37 2011/12/06 11:37

Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다