blog home

be cautious when using window.opener

Posted by Jen in coding front-end on June 15th, 2009

I am talking about window.opener in JavaScript. By defining the attributes of this window.opener, you basically got to control some behavior of the parent window. That sounds cool but might be uncool in some situations as well. For example, when you do this, in order to show some page in the parent window:

<a href=”javascript:window.opener.location=’somewhere”>going somewhere in parent window</a>

It may not work at all, because from this current page, you have no control of where it came from. The user may get the URL of this current page, past it to the address bar directly and there will be no parent page of it all. In this situation, the link on this current page will go nowhere.

Well, just some a little issue I fixed from some badly coded website.

Leave a Reply