userAgent只讀屬性返回瀏覽器發(fā)送給服務(wù)器的user-agent報(bào)頭的值。
navigator.userAgent
var x = navigator.userAgent; document.querySelector("#output").innerHTML = x;測(cè)試看看?/?
所有瀏覽器完全支持userAgent屬性:
屬性 | ![]() | ![]() | ![]() | ![]() | ![]() |
userAgent | 是 | 是 | 是 | 是 | 是 |
返回值: | 一個(gè)字符串,表示當(dāng)前瀏覽器的用戶代理字符串 |
---|
此示例顯示所有Navigator屬性:
var txt = ""; txt += "<p>Browser CodeName: " + navigator.appCodeName + "</p>"; txt += "<p>Browser Name: " + navigator.appName + "</p>"; txt += "<p>Browser Version: " + navigator.appVersion + "</p>"; txt += "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>"; txt += "<p>Browser Language: " + navigator.language + "</p>"; txt += "<p>Browser Online: " + navigator.onLine + "</p>"; txt += "<p>Platform: " + navigator.platform + "</p>"; txt += "<p>User-agent header: " + navigator.userAgent + "</p>"; document.write(txt);測(cè)試看看?/?
Navigator參考:navigator.appCodeName屬性
Navigator參考:navigator.appname屬性
Navigator參考:navigator.cookieEnabled屬性
Navigator參考:navigator.language屬性
Navigator參考:navigator.onLine屬性
Navigator參考:navigator.product屬性