前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >javascript_获取浏览器属性

javascript_获取浏览器属性

作者头像
机器学习和大数据挖掘
发布2019-07-02 09:36:31
6620
发布2019-07-02 09:36:31
举报
文章被收录于专栏:数据挖掘数据挖掘
代码语言:javascript
复制
navigator.appName:浏览器名称;
navigator.appVersion:浏览器版本;
navigator.language:浏览器设置的语言;
navigator.platform:操作系统类型;
navigator.userAgent:浏览器设定的User-Agent字符串。
代码语言:javascript
复制
'use strict';
alert('appName = ' + navigator.appName + '\n' +
      'appVersion = ' + navigator.appVersion + '\n' +
      'language = ' + navigator.language + '\n' +
      'platform = ' + navigator.platform + '\n' +
      'userAgent = ' + navigator.userAgent);
代码语言:javascript
复制
screen.width:屏幕宽度,以像素为单位;
screen.height:屏幕高度,以像素为单位;
screen.colorDepth:返回颜色位数,如8、16、24。
代码语言:javascript
复制
'use strict';
alert('Screen size = ' + screen.width + ' x ' + screen.height);

http://www.example.com:8080/path/index.html?a=1&b=2#TOP

代码语言:javascript
复制
location.protocol; // 'http'
location.host; // 'www.example.com'
location.port; // '8080'
location.pathname; // '/path/index.html'
location.search; // '?a=1&b=2'
location.hash; // 'TOP'
代码语言:javascript
复制
'use strict';
if (confirm('重新加载当前页' + location.href + '?')) {
    location.reload();
} else {
    location.assign('/discuss'); // 设置一个新的URL地址
}
代码语言:javascript
复制
'use strict';
// 获取当前浏览器title
alert(document.title)
// 更改title
document.title = '百哥么么哒';
代码语言:javascript
复制
// 获取cookie
alert(document.cookie)
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-12-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档