This can be done, but not in different domains.
If you want to force the original window to alert the variable:
window.opener.alert(variable);
TestCase: Type javascript:void window.open("http://stackoverflow.com/");in this window. A new window will open.
Type javascript:void window.opener.alert(location.href);in the location bar of the new window and press Enter. A warning window will appear in the original window.
I successfully completed this in FireFox 3.6.22 and the latest version of Chromium. When I open "http://www.example.com/" instead of "http://stackoverflow.com/", a JavaScript error occurs caused by a policy of the same origin.