开发者

Javascript: Closing opened window from within

Is it possible to close opened window from within?

For example i have opened window with some external domain, t开发者_开发技巧hen it performs some auth and redirect back to my webpage.

Is it possible to close windows after that?

Thanks ;)


If you want to close the window that you're currently in, you can use the following code:

self.close();


When you open the window, assign it to some variable:

authWindow = window.open("");

Then when you're done with it, you can close it:

authWindow.close()


var popupWindow = window.open(.....);
popupWindow.close();


var w = window.open(/*arguments*/);

Now w is DOMWindow object.

w.opener === window; //true
w.close();

After that value of the opener property is null

w.opener === null; //true

I hope this helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜