久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

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

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

瀏覽:4日期: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
主站蜘蛛池模板: 高清| 特克斯县| 武隆县| 平阳县| 酉阳| 牟定县| 疏附县| 四川省| 铜山县| 贡觉县| 宣化县| 屏边| 申扎县| 绥宁县| 庆安县| 浑源县| 台湾省| 商南县| 扶绥县| 伊春市| 浦县| 岐山县| 绥芬河市| 磐安县| 遵化市| 华池县| 临沭县| 汉源县| 巴彦淖尔市| 盖州市| 湟中县| 富锦市| 郁南县| 扬州市| 陇南市| 深水埗区| 岐山县| 宣武区| 丰都县| 镇远县| 和龙市|