Js操作BOM对象

7.操作BOM对象 (重点)

JavaScript和浏览器关系?

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

BOM:浏览器对象模型

  • IE
  • Chrome
  • Safari
  • FireFox

window

window代表浏览器窗口

window.innerHeight
205
window.Navigator
Navigator,封装了浏览器的信息

navigator.appName
"Netscape"
navigator.appVersion
"5.0 (Windows)"
navigator.userAgent
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
navigator.platform
"Win32"

大多数时候,我们不会使用navigator对象,因为会被人为修改!

不建议使用这些属性来判断和编写代码

screen

代表屏幕尺寸
screen.width
1920
screen.height
1080

location(重要)

location代表当前页面的URL信息

host: "localhost:63342"
href: "http://localhost:63342/JavaScript/lesson02/7.class%E7%BB%A7%E6%89%BF.html?_ijt=d1egvfrpk63uirlf30qvg6f668"
protocol: "http:"
reload: function reload()  //刷新网页
//设置新的地址
location.assigh('里面写网址')

document

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

document.title
"百度一下,你就知道"
document.title='慢动作'
"慢动作"

获取具体的文档树节点

<dl id="">
    <dt>JAVA</dt>
    <dt>JAVASE</dt>
    <dt>JAVAEE</dt>
</dl>
<script>
    let dl = document.getElementById('app');
</script>
</body>

获取cookie

document.cookie
""

劫持cookie原理

<script src = "aa.js"> </script>	
获取你的cookie上传到他的服务器

服务器端可以设置cookie:httpOnly

history 代表浏览器的历史记录

history.back() //后退
undefined
history.forward()  //前进
undefined

转载https://www.cnblogs.com/F017/p/10967421.html

posted @ 2021-03-15 10:00  岁月-伤  阅读(71)  评论(0)    收藏  举报