javascript – Get Browser Type

取得瀏覽器種類

1
2
3
4
5
6
7
8
9
10
function getbrowser() {
    var agt = navigator.userAgent.toLowerCase();
    if (agt.indexOf('msie') != -1) return "msie";
    if (agt.indexOf('firefox') != -1) return "firefox";
    if (agt.indexOf('safari') != -1) return "safari";
    if (agt.indexOf('seamonkey') != -1) return "seamonkey";
    if (agt.indexOf('netscape') != -1) return "netscape";
    if (agt.indexOf('opera') != -1) return "opera";
    return "unknown";
}