opener is a reference to the window object of an open document. That is, you have access to the global javascript namespace for the open window.
eg.
<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> <script type="text/javascript"> function foo(url) { </script> </head> <body> <div id="d1">...</div> <button onclick="window.open('?');">new window</button> <button onclick="foo(document.URL);">propagte url</button> </body> </html>
if you click "spread url" in the popup window (in any), the function call will go to the first non-popup window (with opener = null).
edit: keep in mind that security restrictions (for example, cross-domain checks) implemented in the browser apply.
edit2: example with history.go (0)
<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> <script type="text/javascript"> function foo() { var context = (null!=opener) ? opener : window; context.history.go(0); } $(document).ready( function() { $('#d1').html("document ready at "+ new Date()); }); </script> </head> <body> <div id="d1">...</div> <button onclick="window.open('?');">new window</button> <button onclick="foo(document.URL);">...and action</button> </body> </html>
source share