Getting Browsers Information from JS Object

本文介绍了一个HTML页面如何通过JavaScript获取并显示浏览器的各种信息,包括名称、版本、平台等,并提供了具体的实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Getting Browsers Information from JS Object

First of all, I prepare my system and my mobile phone.

System is ubuntu desktop. So I install opera, Firefox, chrome, Midori.

Mobile phone is G7, so I install go, opera mini, uc, mathon and G7 internet browser.
Actually, only 2 of the browsers on G7 can access local web server: mathon and G7 internet browser.

My html page navigator.html:
<html>
<head>
<title>JavaScript Master-Navigator</title>
<script type="text/javascript">
function write2HTML(name,value){
document.write("<p>" + name + ": ");
document.write(value + "</p>");
}

var x = navigator;

document.write("<h1>JavaScript Navigator</h1>");

write2HTML("AppName",x.appName);

write2HTML("Vendor",x.vendor);

write2HTML("VendorSub",x.vendorSub);

write2HTML("App Version",x.appVersion);

//for example: Mozilla
write2HTML("App Code Name",x.appCodeName);

write2HTML("cookieEnabled",x.cookieEnabled);

write2HTML("userAgent",x.userAgent);

//additional version messages
write2HTML("appMinorVersion",x.appMinorVersion);

write2HTML("browserLanguage",x.browserLanguage);

write2HTML("language",x.language);

write2HTML("systemLanguage",x.systemLanguage);

write2HTML("userLanguage",x.userLanguage);

write2HTML("cpuClass",x.cpuClass);

write2HTML("oscpu",x.oscpu);

write2HTML("javaEnabled",x.javaEnabled());

//the browser is or not online to internet
write2HTML("onLine",x.onLine);

//platform
write2HTML("platform",x.platform);

//mime types which registered on the device
//MimeType description/type/enabledPlugin/suffixes
//DOMPlugin description/filename/length(The quantity of plug in associated MimeType objects)/name
document.write("<p>MimeTypes: ");
for(var i = 0;i<x.mimeTypes.length;i=i+1){
document.write(x.mimeTypes[i].enabledPlugin.name + ",");
if(i == 5){
break;
}
}
document.write("</p>");

//plugins on the device
//DOMPluginArray
//DOMPlugin description/filename/length(The quantity of plug in associated MimeType objects)/name
document.write("<p>Plugins: ");
for(var i = 0;i<x.plugins.length;i=i+1){
document.write(x.plugins[i].name);
if(i == 5){
break;
}
}
document.write("</p>");

//preference
write2HTML("Preference",x.preference);

//product
write2HTML("Product",x.product);

//productSub
write2HTML("ProductSub",x.productSub);

//opsProfile
write2HTML("OpsProfile",x.opsProfile);

//userProfile
write2HTML("UserProfile",x.userProfile);

//securityPolicy
write2HTML("SecurityPolicy",x.securityPolicy);
</script>
</head>
<body>
</body>
</html>

my html page monitor.html:
<html>
<head>
<title>JavaScript Master-Monitor</title>
<script type="text/javascript">

function write2HTML(name,value){
document.write("<p>" + name + ": ");
document.write(value + "</p>");
}

var s = screen;

document.write("<h1>JavaScript Monitor</h1>");

write2HTML("availHeight",s.availHeight);

write2HTML("availWidth",s.availWidth);

write2HTML("colorDepth",s.colorDepth);

write2HTML("height",s.height);

write2HTML("width",s.width);
</script>
</head>
<body>
</body>
</html>

my html page location.html:
<html>
<head>
<title>JavaScript Master-Navigator</title>
<script type="text/javascript">
function write2HTML(name,value){
document.write("<p>" + name + ": ");
document.write(value + "</p>");
}

var l = window.location;
document.write("<h1>JavaScript Location</h1>");

write2HTML("Hash",l.hash);

write2HTML("Host",l.host);

write2HTML("Hostname",l.hostname);

write2HTML("Href",l.href);

write2HTML("Pathname",l.pathname);

write2HTML("Port",l.port);

write2HTML("Protocol",l.protocol);

write2HTML("Search",l.search);

write2HTML("Target",l.target);


</script>
</head>
<body>
</body>
</html>


references:
http://www.w3school.com.cn/js/js_browser.asp
http://www.comptechdoc.org/independent/web/cgi/javamanual/javamimetype.html
http://www.comptechdoc.org/independent/web/cgi/javamanual/javalocation.html
http://www.gootry.com/java-height/article/100819203028/246
http://www.gootry.com/java-height/article/100820212451/248
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值