偵測瀏覽器版本
<script type=”text/javascript”>
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
if (checkIt(’konqueror’))
{
browser = “Konqueror”;
OS = “Linux”;
}
else if (checkIt(’safari’)) browser = “Safari”
else if (checkIt(’omniweb’)) browser = “OmniWeb”
else if (checkIt(’opera’)) browser = “Opera”
else if (checkIt(’webtv’)) browser = “WebTV”;
else if (checkIt(’icab’)) browser = “iCab”
else if (checkIt(’msie’)) browser = “Internet Explorer”
else if (!checkIt(’compatible’))
{
browser = “Netscape Navigator”
version = detect.charAt(8);
}
else browser = “An unknown browser”;
if (!version) version = detect.charAt(place + thestring.length);
if (!OS)
{
if (checkIt(’linux’)) OS = “Linux”;
else if (checkIt(’x11′)) OS = “Unix”;
else if (checkIt(’mac’)) OS = “Mac”
else if (checkIt(’win’)) OS = “Windows”
else OS = “an unknown operating system”;
}
function checkIt(string)
{
place = detect.indexOf(string) + 1;
thestring = string;
return place;
}
</script>
<script>document.write(”OS:”+OS + “browser:”+browser + “version:”+version + “thestring:”+thestring)</script>
<script>document.write(navigator.userAgent)</script>
這個功能還蠻有趣的,在下Blog搬家完成後,也要來試看看,謝謝。
PS:不小心發現一個錯字:「針」測,應用是「偵」測,嘿嘿!
哈哈 謝謝
平常MSN都不選字 果然不是好習慣ˊˋ