JavaScript-操作BOM对象

B:浏览器
BOM:浏览器对象模型

浏览器介绍
·JavaScript和浏览器关系?
JavaScript诞生为了能够在浏览器中运行
IE、Chrome、FireFox

window代表浏览器窗口



Navigator
·Navigator封装了浏览器的信息

navigator.appVersion
'5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39'
navigator.userAgent
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36 Edg/101.0.1210.39'
navigator.platform
'Win32'

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

screen

screen.width
1536
screen.height
864

location(*)
location代表当前页面的URL信息

host:主机
document
document代表当前的页面
获取具体的文档树节点

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <dl id="app">
        <dt>java</dt>
        <dd>javase</dd>
    </dl>
    <script>
        var dl = document.getElementById('app');
    </script>
</body>
</html>

history

posted on 2022-05-14 10:12  言语说  阅读(20)  评论(0编辑  收藏  举报

导航