JavaScript学习笔记- window对象
It has been 1485 days since the last update, the content of the article may be outdated.
windows
get the inner size of browser:windows.innerWidth
windows.innerHeight
get the global size of browser:windows.outerWidth
windows.outerHeight
navigator
get information of browser
navigator.appName:浏览器名称;
navigator.appVersion:浏览器版本;
navigator.language:浏览器设置的语言;
navigator.platform:操作系统类型;
navigator.userAgent:浏览器设定的User-Agent字符串。
screen
use screen
to get screen information:
screen.width:
screen.height:
screen.colorDepth:
location
for a url=http://www.example.com:8080/path/index.html?a=1&b=2#TOP
plaintext
location.href : get the current url; |
加载一个新页面,可以调用location.assign()
。如果要重新加载当前页面,调用location.reload()方法非常方便
document
document对象表示当前页面。由于HTML在浏览器中以DOM形式表示为树形结构,document对象就是整个DOM树的根节点
document的title属性是从HTML文档中的
plaintext
document.title = '努力学习JavaScript!'; |
用document对象提供的getElementById()和getElementsByTagName()可以按ID获得一个DOM节点和按Tag名称获得一组DOM节点
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment