国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

JavaScript中的location、history、navigator對象實(shí)例介紹

瀏覽:88日期:2022-06-10 14:58:02

1.location

//地址欄上#及后面的內(nèi)容
console.log(window.location.hash);
//主機(jī)名及端口號
console.log(window.location.host);
//主機(jī)名
console.log(window.location.hostname);
//文件的路徑---相對路徑
console.log(window.location.pathname);
//端口號
console.log(window.location.port);
//協(xié)議
console.log(window.location.protocol);
//搜索的內(nèi)容
console.log(window.location.search);
//設(shè)置跳轉(zhuǎn)的頁面的地址
location.;//屬性----------------->必須記住
location.assign("http://www.jb51.net");//方法
//重新加載--刷新
location.reload();
//沒有歷史記錄
location.replace("http://www.jb51.net");

2.history

<body>
<input type="button" value="跳過去" id="btn1"/>
<input type="button" value="前進(jìn)" id="btn2"/>
<script>
    //跳轉(zhuǎn)的
    document.getElementById("btn1").onclick = function () {
window.location.;
    };
    //前進(jìn)
    document.getElementById("btn2").onclick = function () {
window.history.forward();
    };
</script>
</body>

歷史記錄的后退和前進(jìn) history: back()后退 forward()前進(jìn) 

3.navigator

<script>
    //通過userAgent可以判斷用戶瀏覽器的類型
    console.log(window.navigator.userAgent);
    //通過platform可以判斷瀏覽器所在的系統(tǒng)平臺類型.
    console.log(window.navigator.platform);
</script>

到此這篇關(guān)于JavaScript中的location、history、navigator對象實(shí)例介紹的文章就介紹到這了,更多相關(guān)js location、history、navigator內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: JavaScript
主站蜘蛛池模板: 黑河市| 安吉县| 雷山县| 锦屏县| 保靖县| 天等县| 育儿| 勐海县| 嘉鱼县| 淮安市| 西宁市| 巴楚县| 五台县| 柳河县| 甘肃省| 胶南市| 武山县| 大理市| 雷波县| 巨鹿县| 遂宁市| 安化县| 临颍县| 十堰市| 咸阳市| 江永县| 文登市| 东乡县| 阜平县| 轮台县| 西畴县| 漯河市| 麻栗坡县| 周宁县| 永靖县| 讷河市| 梁平县| 澄迈县| 邛崃市| 丹巴县| 措勤县|