Javascript ตรวจ Browser อันล่าสุด
เขียนโดย
paween
ตามนี้เลยครับ
<script language=JavaScript>
name = "";
Version = "";
dataget = navigator.userAgent;
document.write(dataget + "</br>");
getBrowser();
function getBrowser(){
if(dataget.indexOf("MSIE") != -1){
name = "Microsoft Internet Explorer";
arrName = dataget.split("MSIE");
Version = parseFloat(arrName[1]);
if(Version == 8 || Version == 9)
{
writeDetail(name, Version);
}
else
{
document.write('<p><b>You still using old Version of Internet Explorer Please Up Grade now for better performance.</b></br>');
document.write("<a href='http://www.ieaddons.com/en/'>Click Here to Download New Version of Internet Explorer!</a>");
}
}
else if(dataget.indexOf("Opera") != -1)
{
keyword = "Version/";
if(dataget.indexOf(keyword) != -1)
{
arrName = dataget.split(keyword);
Version = parseFloat(arrName[1]);
name = "Opera";
writeDetail(name, Version);
}else{
keyword = "Opera Mini/";
arrName = dataget.split(keyword);
Version = parseFloat(arrName[1]);
name = "Opera Mini";
writeDetail(name, Version);
}
}
else if(dataget.indexOf("Chrome/") != -1)
{
arrName = dataget.split("Chrome/");
Version = parseFloat(arrName[1]);
name = "Chrome";
writeDetail(name, Version);
}
else if(dataget.indexOf("Safari") != -1)
{
if(dataget.indexOf("iPod") != -1){
document.write('<p>You access from iPod</p>')
}
else if(dataget.indexOf("iPhone") != -1){
document.write('<p>You access from iPhone</p>')
}
else if(dataget.indexOf("Version/") != -1)
{
arrName = dataget.split("Version/");
Version = parseFloat(arrName[1]);
name = "Safari";
writeDetail(name, Version);
}
}
else if(dataget.indexOf("Firefox/") != -1)
{
arrName = dataget.split("Firefox/");
Version = parseFloat(arrName[1]);
name = "Firefox";
writeDetail(name, Version);
}
}
function writeDetail(browsName, browsVer){
document.write('<p>Now you use <b>' + browsName + '</b> Version <b>' + browsVer +'</b></p>');
}
</script>
ผลงานนี้ ใช้สัญญาอนุญาตของครีเอทีฟคอมมอนส์แบบ แสดงที่มา-ไม่ใช้เพื่อการค้า-ไม่ดัดแปลง 3.0 ต้นฉบับ
แจ้ง Blog ไม่เหมาะสม
10 ต.ค. 53
287
0
ความคิดเห็น