今天小編給大家分享的是window.location.href的作用有哪些,相信很多人都不太了解,為了讓大家更加了解window.location.href的作用,所以給大家總結(jié)了以下內(nèi)容,一起往下看吧。一定會有所收獲的哦。
window.location
對象可用于獲取當(dāng)前頁面地址(URL)并把瀏覽器重定向到新頁面。
window.location 對象可不帶 window 前綴書寫。
window.location.href
window.location.href
屬性返回當(dāng)前頁面的 URL。
在js中,window.location.href
經(jīng)常用于頁面跳轉(zhuǎn)。它主要有如下幾種用法:
1、在當(dāng)前頁面打開URL頁面。
需要注意的是window.location.href=window.location.href
與window.location.reload()
都是刷新當(dāng)前頁面。區(qū)別在于是否有提交數(shù)據(jù)。當(dāng)有提交數(shù)據(jù)時,window.location.Reload()
會提示是否提交,window.location.href=window.location.href;
則是向指定的url提交數(shù)據(jù)
self.location.href="url" location.href="url" window.location.href="url" this.location.href="url"
2、在父頁面打開URL頁面。
parent.location.href="url"
3、在頂層頁面打開URL頁面。
top.location.href="url"
以上就是window.location.href的作用有哪些的簡略介紹,當(dāng)然詳細(xì)使用上面的不同還得要大家自己使用過才領(lǐng)會。如果想了解更多,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道哦!
網(wǎng)站欄目:window.location.href的作用有哪些-創(chuàng)新互聯(lián)
本文來源:http://m.newbst.com/article42/dcesec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗、移動網(wǎng)站建設(shè)、ChatGPT、網(wǎng)站維護(hù)、企業(yè)網(wǎng)站制作、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容