更改已開啟的彈出視窗的 url
P粉348915572
P粉348915572 2024-03-25 17:35:47
0
2
415

是否可以更改彈出視窗的 url。

假設我打開一個彈出視窗:

function pop1(){
    window.open('http://google.com','wind1');   
}

能否將彈出視窗「wind1」的 URL 改為「http://msn.com」。帶有 location.href 或任何其他解決方案的東西。

P粉348915572
P粉348915572

全部回覆(2)
P粉204136428

對我來說,當我只更改 url 的末尾(參數部分)時,我使用了一個小技巧: 在使用新的相似 url 之前加載不同的 url。 我選擇使用“about:blank”,但可以使用任何網站網址。

self.location = "about:blank";
self.location = desired_url;

//this code works fine both in Mozilla Firefox as in Chrome

請注意,location = site;與 location.href = site.
相同 我僅使用 location.href 來讀取當前 url。

P粉135292805

雷雷

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!