Referencing the Opener

The opener is the window that the new window was opened from.
To prevent error messages being generated you should always check that the opener has not been closed by using

if(opener&&!opener.closed)

Open Example Window

 

Page1.htm

<script type="text/javascript">
function fromNewWin(){
newWin.document.getElementById("popdisplay").innerHTML="The link in this popup called a  function in the opener which populated this div"
document.getElementById('openerdisplay').innerHTML=" "
}
</script>

<a href="#null" onclick="newWin=window.open('page2.htm','mywin','left=300,top=300,width=500,height=200')">Open Example Window</a>

<div id="openerdisplay" style="border:1px dashed black"></div>

Page2.htm

<script type="text/javascript">
function sendToOpener(){
if(opener&&!opener.closed){
opener.document.getElementById('openerdisplay').innerHTML="The link in the popup ran a function in the popup to populated this div in the opener"
document.getElementById('popdisplay').innerHTML=" "
}
}
</script>

<a href="#null" onclick="if(opener&&!opener.closed){opener.fromNewWin()}"">Run function in opener</a>
<a href="#null" onclick="sendToOpener()">Send to opener</a>

<div id="popdisplay" style="border:1px dashed black"></div>


If the document in the opener changes

If you create a new window and the document in the opener is liable to be changed the check for if(opener && !opener.closed) will not be sufficient as this will still return true
If you try to reference elements, functions, or objects in the opener errors will be thrown up because the page containing the elements, functions, or objects may not be there, you should therefore also check for what you what to reference.

if(opener && !opener.closed && opener.whatever){

or

if(opener && !opener.closed){
if(opener.whatever){

}
}

IE does not lose the reference to the opening window until all its windows are closed
Firefox does lose the reference when the opening window is shut