6.JS操作BOM对象

6.操作BOM对象(重点)

浏览器介绍

JavaScript和浏览器的关系

JavaScript诞生就是为了能够让他在浏览器中运行

BOM:浏览器对象模型

window

window代表浏览器窗口

Navigator

大多数时候,我们不会使用Navigator对象,因为会被人为更改

screen

 屏幕尺寸
 creen.width
 1536
 screen.height
 864

location(重要)

location代表当前页面的URL信息

 host: "www.baidu.com"
 href: "https://www.baidu.com/"
 protocol: "https:"
 reload: ƒ reload()//重新加载(刷新网页)
 location.assign('http://bilibili.com')//设置新的地址

document

document代表当前页面,HTML DOM文档树

 document.title
 '百度一下,你就知道'
 document.title="233"
 '233'

获取具体的文档树节点

 <dl id="app">
     <dt>Java</dt>
     <dd>JavaEE</dd>
     <dd>JavaSE</dd>
 </dl>
 <script>
    var dl= document.getElementById('app')
 </script>

获取cookie

 document.cookie

服务器端可以设置cookie:httpOnly

history

 history.back()//后退
 history.forward()//前进
 
posted @ 2022-09-07 22:06  l希尔瓦娜斯l  阅读(21)  评论(0)    收藏  举报