[javascript]取得瀏覽器資訊
整理一下供自己參考~
DetectBroserInfo.js
function PrintVersion() {
var msg = "<br\>瀏覽器相關資訊<br\><br\>";
msg += "瀏覽器名稱 : " + navigator.appName + "<br\>";
msg += "瀏覽器版本 : " + navigator.appVersion + "<br\>";
msg += "瀏覽器程式碼 : " + navigator.appCodeName + "<br\>";
msg += "cookie功能是否開啟 : " + navigator.cookieEnabled + "<br\>";
msg += ShowMimeContent();
msg += "作業系統 : " + navigator.platform + "<br\>";
msg += "HTTP協定使用者代理 : " + navigator.userAgent + "<br\>";
document.write(msg);
}
//顯示Mime內容
function ShowMimeContent() {
var msg = "";
if (navigator.mimeTypes.length == 0) {
msg += "mimeTypes.length : " + navigator.mimeTypes.length + "<br\>";
return msg;
}
msg += "mimeTypes.length : " + navigator.mimeTypes.length + "<br\>";
msg += "mimeTypes : <br\>";
for (var myIndex = 0; myIndex < navigator.mimeTypes.length; myIndex++) {
for (var myProperty in navigator.mimeTypes[myIndex]) {
msg += myProperty;
msg += ":";
msg += navigator.mimeTypes[myIndex][myProperty];
msg += "<br\>";
}
msg += "<br\>";
}
return msg;
}
使用DotNet取得瀏覽器資訊(BrowserInfo.aspx.cs)
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Program_BrowserInfo_BrowserInfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpBrowserCapabilities bs = Request.Browser;
Response.Write("瀏覽器的相關規格與訊息:");
Response.Write("<hr>");
Response.Write("類型:" + bs.Type + "<br/>");
Response.Write("名稱:" + bs.Browser + "<br/>");
Response.Write("版本:" + bs.Version + "<br/>");
Response.Write("標籤:" + bs.Id + "<br/>");
Response.Write("操作平台:" + bs.Platform + "<br/>");
Response.Write("是否支援框架:" + bs.Frames + "<br/>");
Response.Write("是否支援表格:" + bs.Tables + "<br/>");
Response.Write("是否支援Cookies:" + bs.Cookies + "<br/>");
Response.Write("是否支援CSS:" + bs.SupportsCss + "<br/>");
Response.Write("是否支援JavaApplets:" + bs.JavaApplets + "<br/>");
Response.Write("是否支援JavaScript:" + bs.EcmaScriptVersion + "<br/>");
Response.Write("JavaScript版本:" + bs.JScriptVersion + "<br/>");
Response.Write("是否支援VBScript:" + bs.VBScript + "<br/>");
Response.Write("是否支援ActiveX:" + bs.ActiveXControls + "<br/>");
Response.Write("<hr>");
Response.Write("客戶端相關規格與訊息:");
Response.Write("<hr>");
Response.Write("客戶端主機名稱:" + Request.UserHostName + "<br/>");
Response.Write("客戶端主機IP:" + Request.UserHostAddress + "<br/>");
Response.Write("客戶端用戶代理訊息:" + Request.UserAgent + "<br/>");
Response.Write("<hr>");
}
}
參考資料