是否可以更改彈出視窗的 url。
假設(shè)我打開(kāi)一個(gè)彈出視窗:
function pop1(){ window.open('http://google.com','wind1'); }
能否將彈出視窗「wind1」的 URL 改為「http://msn.com」。帶有 location.href 或任何其他解決方案的東西。
對(duì)我來(lái)說(shuō),當(dāng)我只更改 url 的末尾(參數(shù)部分)時(shí),我使用了一個(gè)小技巧: 在使用新的相似 url 之前加載不同的 url。 我選擇使用“about:blank”,但可以使用任何網(wǎng)站網(wǎng)址。
self.location = "about:blank"; self.location = desired_url; //this code works fine both in Mozilla Firefox as in Chrome
請(qǐng)注意,location = site;與 location.href = site.
相同
我僅使用 location.href 來(lái)讀取當(dāng)前 url。