开发者

Changing the address of the opener window in IE8

开发者 https://www.devze.com 2022-12-08 23:58 出处:网络
From a child popup window (opened using window.open), I am trying to change the URL of the window that opened me, e.g.

From a child popup window (opened using window.open), I am trying to change the URL of the window that opened me, e.g.

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

In all browsers this works wonderfully, except for IE8 (and I am somewhat sure it worked in previous IE8. Maybe a security update kills this).

In IE8 what happens is that the line above is treated as a request to open a NEW window with the address and the original opener window stays the same. And, since I am not putting this line inside an oncli开发者_StackOverflow中文版ck event, this is treated as a popup.

So how do I do this in IE8? How do I change the opener location?


It looks like this is just not possible. I got no answer from anybody and all my research indicated that this is just another way MS added to block popups.


try to move action into parent window, like this:

//parent.htm
function changeUrl(url) {
  location.href = url;
  window.reload();
}

window.open("child.htm");

.....

//child.htm
window.opener.changeUrl(url);


try this: on the opener window define a function called goto ;-)

function goto(url){ window.location.href = url; }

now from the child window call window.opener.goto(url);

0

精彩评论

暂无评论...
验证码 换一张
取 消