W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
該 Window.navigator 只讀屬性返回對 Navigator 對象的引用,可以查詢有關(guān)運行腳本的應用程序的信息。
navigatorObject = window.navigator
var sBrowser, sUsrAg = navigator.userAgent;
if(sUsrAg.indexOf("Chrome") > -1) {
sBrowser = "Google Chrome";
} else if (sUsrAg.indexOf("Safari") > -1) {
sBrowser = "Apple Safari";
} else if (sUsrAg.indexOf("Opera") > -1) {
sBrowser = "Opera";
} else if (sUsrAg.indexOf("Firefox") > -1) {
sBrowser = "Mozilla Firefox";
} else if (sUsrAg.indexOf("MSIE") > -1) {
sBrowser = "Microsoft Internet Explorer";
}
alert("You are using: " + sBrowser);
function getBrowserId () {
var
aKeys = ["MSIE", "Firefox", "Safari", "Chrome", "Opera"],
sUsrAg = navigator.userAgent, nIdx = aKeys.length - 1;
for (nIdx; nIdx > -1 && sUsrAg.indexOf(aKeys[nIdx]) === -1; nIdx--);
return nIdx
}
console.log(getBrowserId());
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: