首页  >  问答  >  正文

更改已打开的弹出窗口的 url

是否可以更改弹出窗口的 url。

假设我打开一个弹出窗口:

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

能否将弹出窗口“wind1”的 URL 更改为“http://msn.com”。带有 location.href 或任何其他解决方案的东西。

P粉348915572P粉348915572207 天前528

全部回复(2)我来回复

  • P粉204136428

    P粉2041364282024-03-26 15:00:45

    对我来说,当我只更改 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。

    回复
    0
  • P粉135292805

    P粉1352928052024-03-26 10:26:29

    雷雷

    回复
    0
  • 取消回复