• DOM与BOM


    <html>
    <head>
        <meta charset="utf-8">
        <title>DOM and BOM</title>
    </head>
    <body>
        <div>此为DOM的部分示例(用id和标签寻找html的元素):</div>
        <p id="intro">Hello HTML!</p>
    
        <p>The DOM is  useful.</p>
        <p id="p1">这是原来的句子</p>
        <p>以下例子是用id来寻找元素:</p>
        <p id="demo"></p>
        <p>以下例子是用标签名称来寻找元素:</p>
        <p id="demo1"></p>
        <div>此为BOM的部分示例(获取当前浏览器窗口的长和宽、获取当前的网站地址):</div>
        <p id="demo2"></p>
        <div>以下展示当前的网站地址:</div>
         <p id="demo3"></p>
        <script>
            var myElement = document.getElementById("intro");
            document.getElementById("demo").innerHTML = 
            "The text from the intro paragraph is: " + myElement.innerHTML;
            var x = document.getElementsByTagName("p");
            document.getElementById("demo1").innerHTML = 
            'The second paragraph (index 1) is: ' + x[1].innerHTML;
            document.getElementById("p1").innerHTML = "本句是用js更改后的句子";
            var w = window.innerWidth
            || document.documentElement.clientWidth
            || document.body.clientWidth;
    
            var h = window.innerHeight
            || document.documentElement.clientHeight
            || document.body.clientHeight;
    
            var x = document.getElementById("demo2");
            x.innerHTML = "当前浏览器的宽为:" + w + ", 高为:" + h + "";
    
            document.getElementById("demo3").innerHTML = "当前网址为:" + window.location.href;
        </script>
    </body>
    </html>
  • 相关阅读:
    Linux目录结构
    Linux简介
    队列、生产者消费者模型
    Process的几个用法和守护进程
    并发编程(初学)
    网络编程知识点小结
    用socketserver模块实现并发
    粘包问题、解决粘包问题和struct模块
    模拟ssh功能和subprocess模块
    socket 套接字编程
  • 原文地址:https://www.cnblogs.com/linlinlina-liu/p/9827289.html
Copyright © 2020-2023  润新知