change url of already opened popup

倾然丶 夕夏残阳落幕 提交于 2019-11-26 22:17:12

问题


Is it possible to change the url of the popup.

Assume I open a popup:

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

Can the url of the popup window 'wind1' be changed to say 'http://msn.com'. Something with location.href or any other solution.


回答1:


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

w1.location.href='http://www.google.com';



回答2:


in the new popup window use this :

$(document).ready(function(){ window.parent.location="http://www.google.com" })




回答3:


For me, as I was changing just the end of the url (parameters part), I used a little trick: Loading a different url before using the new similar url. I chose to use 'about:blank', but any website url could be used.

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

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

Notice that just location = site; does the same as location.href = site.
I use location.href only to READ the current url.



来源:https://stackoverflow.com/questions/10774211/change-url-of-already-opened-popup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!