Home  >  Q&A  >  body text

Change the url of an open popup window

Whether it is possible to change the url of the pop-up window.

Suppose I open a popup window:

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

Can you change the URL of the pop-up window "wind1" to "http://msn.com". Something with location.href or any other solution.

P粉348915572P粉348915572207 days ago527

reply all(2)I'll reply

  • P粉204136428

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

    For me, when I only changed the end of the url (parameter part), I used a little trick: Load different urls before using new similar urls. I chose to use "about:blank", but any website URL can be used.

    self.location = "about:blank";
    self.location = desired_url;
    
    //this code works fine both in Mozilla Firefox as in Chrome

    Please note that location = site; is the same as location.href = site.
    I only use location.href to read the current url.

    reply
    0
  • P粉135292805

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

    var w1 = window.open('http://www.canop.org','wind1');
    
    w1.location.href='http://www.google.com';

    reply
    0
  • Cancelreply