title: How to add an onclick function to an element in opener window?
body: <p>I work on a webpage that opens a popup with a picture selector. The pictures added to a selection list are immediately cloned as thumbnails to opener window - that part works fine.</p>
  
  <p>Problem occurs when I try to make these thumbnails clickable, like this: </p>
  
  <pre><code>opener.document.getElementById("someid").onclick = function(){ alert("bam!"); }    
  </code></pre>
  
  <p>So far I only managed to have this working when a popup window is still opened (instead of plain alert(...) I used <code>opener.window.alert("bam!")</code>). However, when I close popup window, clicking the thumbnails results in errors. </p>
  
  <p>Anyone out there who had similar problem and got it working? Thanks in advance.</p>
  
  <p>UPDATE:</p>
  
  <p>OK, I found not the prettiest solution, but so far it works. I had to declare extra function in opener window:</p>
  
  <pre><code>function addbam(id){
      document.getElementById(id).onclick = function(){ alert("bam!"); }
  }
  </code></pre>
  
  <p>And in a popup window:</p>
  
  <pre><code>opener.addbam("someid");
  </code></pre>
  
  <p>If this solution survives multi-browser test, it will stay with me, however I'm pretty sure it should be possible to remove "wrong" scope from such onclick declarations in much straightforward manner.</p>
  
  <p>Thanks guys, your suggestions got me thinking more productive way.</p>