操作bom对象
bom:浏览器对象模型
window对象 代表浏览器窗口
//window.alert(22) window.innerHeight //595 window.innerWidth //131 window.innerWidth //322 window.outerHeight //824 window.outerWidth //1536
Navigator
//Navigator封装了浏览器信息 navigator.appVersion //'5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' navigator.platform //'Win32'
//不建议使用navigator属性判断和编写代码
screen
//screen代表屏幕尺寸 screen.width //1536 screen.height //864
location 代表当前页面的url信息
/* host:"www.baidu.com" hostname:"www.baidu.com" href:"https://www.baidu.com/" protocol: "https:" reload: reload()//刷新网页 */ //跳转至其他网页 location.assign('http://www.bilibili.com')
其他
//document代表当前的页面,html dom文档树 document.title //'百度一下,你就知道' //获取cookie document.cookie //'BIDUPSID=33C2B248AF50BA4D1532930E18F354D1; PSTM=1607833850; BAIDUID=857915D13671CA35E7044F3C1DBD4953:FG=1; BAIDUID_BFESS=857915D13671CA35E7044F3C1DBD4953:FG=1; ZFY=1KJ7uzmcLFByZ:A2fasn:Aaq5bnVHNZfWqnrA9SkAWql0:C; baikeVisitId=a2e509a7-59f6-4f0a-afab-df4491f9c721; BD_HOME=1; H_PS_PSSID=37856_36555_37733_37767_37625_37766_37866_36802_37761_37850_26350_22159; BD_UPN=12314753; BA_HECTOR=a08ga0al0184a1ag20a08mik1hogpp61h' //history 代表浏览器的历史记录 history.back() history.forward()
操作dom对象
浏览器就是一个dom树型结构
//更新:更新dom节点 //删除:删除dom节点 //添加:添加一个新的dom节点 document.getElementsByTagName('h1') document.getElementById('p1') document.getElementsByClassName('p2') var father = document.getElementById('father') var children = father.children//获取父节点下的所有子节点
标签:www,浏览器,dom,day37,screen,window,bom,document From: https://www.cnblogs.com/GUGUZIZI/p/16953763.html