|
|
|
script php ตรวจสอบ browser ผมลองค้นหาในเว็บนี้แล้วไปเจอ มาครับ แต่ทำไมมัน ออกมันมาไม่ตรงครับ |
|
|
|
|
|
|
|
ต้วนี้ครับ ผมใช้ IE9 เปิดหน้าเว็บ แต่มันบอกว่าผมใช้ IE7 เปิดครับ ผมรันบน localhost นะครับ
Code (PHP)
function getbrowser(){
$agent = $_SERVER['HTTP_USER_AGENT'];
if(eregi("Netcaptor", $agent)){ $browser = "Netcaptor";
} elseif(eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}", $agent, $ver) || eregi("(opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}", $agent, $ver)){ $browser = "Opera $ver[2]";
} elseif(eregi("(konqueror)/([0-9]{1,2}.[0-9]{1,3})", $agent, $ver)){ $browser = "Konqueror $ver[2]";
} elseif(eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $agent, $ver)){ $browser = "Lynx $ver[2]";
} elseif(eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})", $agent, $ver)){ $browser = "Internet Explorer $ver[2]";
} elseif(eregi("Links", $agent)){ $browser = "Lynx";
} elseif(eregi("(Firebird/)([0-9]{1,2}.[0-9]{1,3}){0,1}", $agent, $ver)){ $browser = "Firebird $ver[2]";
} elseif(eregi("(Firefox/)([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $agent, $ver)){ $browser = "FireFox $ver[2]";
} elseif(eregi("Mozilla/5",$agent)){$browser = "Netscape 5";
} elseif(eregi("Gecko", $agent)){ $browser = "Mozilla";
} elseif(eregi("Safari",$agent)){ $browser = "OS-X Safari";
} elseif(eregi("(netscape6)/(6.[0-9]{1,3})", $agent, $ver)){ $browser = "Netscape $ver[2]";
} elseif(eregi("(Mozilla)/([0-9]{1,2}.[0-9]{1,3})", $agent, $ver)){ $browser = "Netscape $ver[2]";
} elseif(eregi("Galeon", $agent)){ $browser = "Galeon";
} elseif(eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $agent, $ver) ){$browser = "Lynx $ver[2]";
} elseif(eregi("Avant Browser", $agent)){ $browser = "Avant";
} elseif(eregi("(omniweb/)([0-9]{1,2}.[0-9]{1,3})", $agent, $ver) ){$browser = "OmniWeb $ver[2]";
} elseif(eregi("ZyBorg|WebCrawler|Slurp|Googlebot|MuscatFerret|ia_archiver", $agent)){ $browser = "Web indexing robot";
} elseif(eregi("(webtv/)([0-9]{1,2}.[0-9]{1,3})", $agent, $ver) ){$browser = "WebTV $ver[2]";
} else {$browser = "Unknown";}
return $browser;
}
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2012-06-15 15:05:26
|
|
|
|
|
Date :
2012-06-15 15:04:51 |
By :
addy_it |
View :
1215 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
jQuery.each(jQuery.browser, function(i, val) {
$("<div>" + i + " : <span>" + val + "</span>").appendTo(document.body);
});
});
</script>
ลองเอาไว้บน tag <head> ดูครับว่าถูกหรือเปล่า
|
|
|
|
|
Date :
2012-06-15 15:31:28 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$agent = $_SERVER['HTTP_USER_AGENT'];
echo $agent;
ดูว่าตรงไหนที่มันผิดเพี้ยนไปครับ
|
|
|
|
|
Date :
2012-06-18 06:12:03 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|