BOM:浏览器对象模型
window
代表浏览器窗口
JavaScript
window.alert(1);
undefined
window.innerHeight
713
window.innerWidth
678
Navigator
封装了浏览器信息
JavaScript
navigator.appName
"Netscape"
navigator.appVersion
"5.0 (Windows)"
navigator.platform
"Win32"
navigator.userAgent
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0"
Screen
代表屏幕尺寸
JavaScript
screen.width
1536
screen.height
864
location
代表当前页面的URL信息
JavaScript
Location https://www.baidu.com/index.php?tn=monline_3_dg
assign: function assign()
hash: ""
host: "www.baidu.com"
hostname: "www.baidu.com"href:
"https://www.baidu.com/index.php?tn=monline_3_dg"origin:
"https://www.baidu.com"
pathname: "/index.php"
port: ""
protocol: "https:"
reload: function reload()replace: function replace()search: "?tn=monline_3_dg"toString: function toString()valueOf: function valueOf()Symbol(Symbol.toPrimitive): undefined
document
代表当前的页面,HTML DOM文档树
JavaScript
document.title
"百度一下,你就知道"
document.title = 'alibaba'
"alibaba"
获取具体的文档树节点
JavaScript
document.getElementById
function getElementById()
document.getElementsByName
function getElementsByName()
document.getElementsByClassName
function getElementsByClassName()
获取Cookie
JavaScript
document.cookie
"NTES_P_UTID=ntDlET5VKK9S2XxoJr3ryOZJ08EdX0Jw|1651939552; nts_mail_user=ichi18594283911@163.com:-1:1; MAIL_PINFO=ichi18594283911@163.com|1651939552|0|mail163|00&99|CN&1651939368&carddav#CN&null#10#0#0|185911&0|mailmaster_android&youdaodict_client&mail163|ichi18594283911@163.com; locale=; face=js6; _ntes_nnid=fafe7b444264b8fd6a34e6b95173675e,1641036670104; _ntes_nuid=fafe7b444264b8fd6a34e6b95173675e; MAIL_SDID=821386009882615808; P_INFO=ichi18594283911@163.com|1651939552|0|mail163|00&99|CN&1651939368&carddav#CN&null#10#0#0|185911&0|mailmaster_android&youdaodict_client&mail163|ichi18594283911@163.com; starttime="
劫持Cookie原理
JavaScript
<script src="aa.js"></script>
//通过ajax获取你的Cookie上传到他的服务器
服务端可以设置Cookie:httpOnly
history
代表浏览器的历史记录
JavaScript
history.forward() //前进
history.back() //后退
扩展:Cooike、Session、Token
Http无状态:
也就是登录一次http就不会记得信息了
Cookie的基本流程:
1.浏览器发起Http请求
2.Set-Cookie
3.Http请求