Javascript Detect Browser
เขียนโดย
paween
____________________________________________________________
เพิ่มการตรวจจับ Chrome for Android สำหรับ Androdi 4.0 ICS
dataget = navigator.userAgent;
getBrowser();
function getBrowser(){
if(dataget.indexOf("MSIE") != -1){
name = "Microsoft Internet Explorer";
arrName = dataget.split("MSIE");
Version = parseFloat(arrName[1]);
if(Version >= 8)
{
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>");
//window.close();
}
}
else if(dataget.indexOf("Opera") != -1)
{
keyword = "Opera Mini/";
if(dataget.indexOf(keyword) != -1)
{
arrName = dataget.split(keyword);
Version = parseFloat(arrName[1]);
name = "Opera Mini";
writeDetail(name, Version);
}else{
keyword = "Version/";
arrName = dataget.split(keyword);
Version = parseFloat(arrName[1]);
name = "Opera";
writeDetail(name, Version);
}
}
else if(dataget.indexOf("RockMelt") != -1)
{
arrName = dataget.split("RockMelt/");
Version = parseFloat(arrName[1]);
name = "RockMelt Social Browser";
writeDetail(name, Version);
}
else if(dataget.indexOf("Chrome/") != -1)
{
if(dataget.indexOf("Android") != -1)
{
document.write('<p>Google Chrome for Android</p>');
}else{
arrName = dataget.split("Chrome/");
Version = parseFloat(arrName[1]);
name = "Chrome";
writeDetail(name, Version);
}
}
else if(dataget.indexOf("Android") != -1)
{
arrName = dataget.split("Android");
Version = parseFloat(arrName[1]);
name = "Android";
writeDetail(name, Version);
}
else if(dataget.indexOf("Safari") != -1)
{
if(dataget.indexOf("iPad") != -1){
document.write('<p>You access from iPad</p>');
}
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("NanohaBrowser/") != -1)
{
arrName = dataget.split("NanohaBrowser/");
Version = parseFloat(arrName[1]);
name = "Nanoha Browser";
writeDetail(name, Version);
}
else if(dataget.indexOf("Firefox/") != -1)
{
arrName = dataget.split("Firefox/");
Version = parseFloat(arrName[1]);
name = "Firefox";
writeDetail(name, Version);
}
else if(dataget.indexOf("Bada/") != -1)
{
arrName = dataget.split("Bada/");
Version = parseFloat(arrName[1]);
name = "Bada";
writeDetail(name, Version);
}
}
function writeDetail(browsName, browsVer){
document.write('<p>Now you use <b>' + browsName + '</b> Version <b>' + browsVer +'</b></p>');
_____________________________________________________-
ผลงานนี้ ใช้สัญญาอนุญาตของครีเอทีฟคอมมอนส์แบบ แสดงที่มา-ไม่ใช้เพื่อการค้า-ไม่ดัดแปลง 3.0 ต้นฉบับ.
แจ้ง Blog ไม่เหมาะสม
29 เม.ย. 55
218
0
ความคิดเห็น