MTAA-RR » news » twhid » geek » window opener:
May 02, 2003
window.opener
posted at 18:10 GMT by T.Whid in /news/twhid/geek
If you want to reference the main browser window from a pop-up window via javascript you use
window.opener
. I know, I know, all you code monkeys out there are like, "of course you doofus!" but I’m no javascript master so bite me.
I needed to do it at work and couldn’t remember how to do it. Interestingly enough, if you use
target="main"
in an anchor tag (after naming the main window via javascript window.name="main"
) then MSIE Windows and Mac will load the HREF in that main window. But Gecko browsers don’t seem to get it (at least not Mozilla 1.0/Windows). What works is onclick="window.opener.¬
location.href='yerhref';"
. That seems to work in everything I tested: Safari, Mac IE 5.2, WinIE 6, Moz 1.0. I don’t test in NS 4 as much as I should. I think in this case I will however.
Now you too can reference the main browser window from a pop-up window via javascript. If you feel like leaving comments on why you might want to do this, feel free. permanent link to this post
MTAA-RR » news » twhid » geek » window opener