六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

JavaScript的BOM

[摘要]這次給大家?guī)鞪avaScript的BOM,使用JavaScript的BOM的注意事項有哪些,下面就是實戰(zhàn)案例,一起來看一下。location對象location對象提供了與當(dāng)前窗口中加載的文檔有關(guān)的信息,還提供了一些導(dǎo)航的功能,它既是window對象的屬性,也是document對象的屬性。語法:...
這次給大家?guī)鞪avaScript的BOM,使用JavaScript的BOM的注意事項有哪些,下面就是實戰(zhàn)案例,一起來看一下。

location對象
location對象提供了與當(dāng)前窗口中加載的文檔有關(guān)的信息,還提供了一些
導(dǎo)航的功能,它既是window對象的屬性,也是document對象的屬性。
語法:location.href
功能:返回當(dāng)前加載頁面的完整URL
說明:location.href與window.location.href等價
語法:location.hash
功能:返回URL中的hash(#號后跟零或多個字符),如果不包含則返回空字符串
語法:location.host
功能:返回服務(wù)器名稱和端口號(如果有)
語法:locationhostname
功能:返回不帶端口號的服務(wù)器名稱。
語法:location.pathname
功能:返回URL中的目錄和(或)文件名。
語法:location.port
功能:返回URL中指定的端口號,如果沒有,返回空字符串。
語法:location.protocol
功能:返回頁面使用的協(xié)議
語法:location.search
功能:返回URL的查詢字符串。這個字符串以問號開頭。
語法:location.replace(url)
功能:重新定向URL
說明:使用location.replace不會再歷時記錄中生成新紀(jì)錄。
語法:location.reload()
功能:重新加載當(dāng)前顯示的頁面。
說明:
location.reload()有肯從緩沖中加載
location.reload(true)從服務(wù)器重新加載
history對象
history對象保存了用戶在瀏覽器中訪問頁面的歷史記錄
語法:history.back()
功能:回到歷史記錄的上一步
說明:相當(dāng)于使用了history.go(-1)
語法:location.forward()
功能:回到歷時記錄的下一步
說明:相當(dāng)于使用了history.go(1)
語法:history.go(-n)
功能:回到歷時記錄的前n步
語法:history.go(n)
功能:回到歷史記錄的后n步
navigator對象
useragent:用來識別瀏覽器名稱,版本,引擎以及操作系統(tǒng)等信息的內(nèi)容。
screen對象
語法:screen.availWidth
功能:返回可用的屏幕寬度
語法:screen.availHeight
功能:返回可用的屏幕高度

location01.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .box1{
            height: 900px;
            background: #ccc;
        }
        .box2{
            height: 500px;
            background-color: #333;
        }
    </style>
</head>
<body>
    <div id="box1"></div>
    <div></div>
    <input type="button" id="btn" value="返回頂部">
    <script>
        btn.onclick = function () {
            location.hash = '#box1';
            console.log(location.hash);
        }
        console.log(location.href);
        console.log(location.hash);
        console.log(location.host);
        console.log(location.hostname);
        console.log(location.pathname);
        console.log(location.port);
        console.log(location.protocol);
        console.log(location.search);
    </script>
</body>
</html>

location02.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <input type="button" value="刷新" id="btn">
    <script>
        /*setTimeout(function () {
            //location.href = "https://www.baidu.com";
            //window.location = "https://www.baidu.com";
            location.replace("https://www.baidu.com");
        },1000);*/
        document.getElementById('btn').onclick = function () {
            location.reload();
            //location.reload(true);
        }
    </script>
</body>
</html>

history01.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <a href="example_2.html">example_2.html</a>
    <input type="button" value="后退" id="btn1">
    <input type="button" value="前進(jìn)" id="btn2">
    <script>
        var btn1 = document.getElementById('btn1');
        var btn2 = document.getElementById('btn2');
        btn1.onclick = function () {
            //history.back();
            history.go(-1);
        }
        btn2.onclick = function () {
            history.forward()
            //history.go(1);
        }
    </script>
</body>
</html>

navigator.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        function getBrowser() {
            var explorer = navigator.userAgent.toLowerCase();
            var browser = "";
            if (explorer.indexOf("msie")>-1) {
                browser = "IE";
            } else if (explorer.indexOf("chrome")>-1){
                browser = 'Chrome';
            } else {
                browser = 'asdf';
            }
            return browser;
        }
        var msg = "您用的是" +getBrowser()+'瀏覽器';
        console.log(msg);
    </script>
</body>
</html>

screen.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        console.log(screen.availWidth);
        console.log(screen.availHeight);
        console.log(window.innerWidth);
        console.log(window.innerHeight);
    </script>
</body>
</html>

相信看了這些案例你已經(jīng)掌握了方法,更多精彩請關(guān)注php中文網(wǎng)其它相關(guān)文章!

相關(guān)閱讀:

ES6 module語法加載 import export

判斷登陸是否失效代碼

如何利用getBoundingClientRect()來實現(xiàn)div容器滾動固定

實現(xiàn)瀑布流布局的倆種方法

以上就是JavaScript的BOM的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!


網(wǎng)站建設(shè)是一個廣義的術(shù)語,涵蓋了許多不同的技能和學(xué)科中所使用的生產(chǎn)和維護(hù)的網(wǎng)站。




標(biāo)簽:JavaScript的BOM 

相關(guān)文章

主站蜘蛛池模板: 青草视频在线观看视频 | 深夜视频在线播放视频在线观看免费观看 | 亚洲第一页综合 | 性色a v 一区 | 中文有码中文字幕免费视频 | 中文字幕精品视频在线观看 | 亚洲区第一页 | 午夜专区| 四虎影视站长工具 | 欧洲美女高清一级毛片 | 午夜在线观看视频在线播放版 | 在线视频一区二区三区 | 医生护士一级毛片 | 中文字幕欧美在线观看 | 啪啪动漫 | 日本高清影院 | 天天色天天操综合网 | 五月婷婷爱 | 亚洲永久免费网站 | 日韩a级一片在线观看 | 日韩精品成人a在线观看 | 婷婷热 | 青草久久网 | 日本成人午夜 | 性生大片一级毛片免费观看 | 在哪里看毛片 | 伊人网站视频 | 天天躁夜夜躁狠狠躁2021 | 在线观看亚洲国产 | 日韩不卡手机视频在线观看 | 青春草在线视频免费观看 | 午夜精品久久久久 | 色噜噜狠狠色综合中国 | 青草免费视频 | 人人天天夜夜 | 中文一区在线观看 | 午夜一区二区三区 | 亚洲综合站 | 亚洲视频三区 | 日韩黄色三级 | 日韩中文字幕在线视频 |