title: Change Parent Window onclick Value From Child Window Via JavaScript
body: <p>Setup:</p>
  
  <p>I'm opening a new window via js that is a classic asp page with one form (yes, classic asp, I know).  That form posts to a processing page where I Response.Write() some inline js to manipulate form elements on the parent page like so.</p>
  
  <pre><code>.Write ("&lt;script language=""javascript""&gt;" &amp; vbcrlf)    
  .Write ("var stopButton = opener.document.getElementById(""timerStop"");" &amp; vbcrlf)
  .Write ("stopButton.style.display = ""inline"";" &amp; vbcrlf)
  .Write ("window.close();" &amp; vbcrlf)
  .Write ("&lt;/script&gt;" &amp; vbcrlf)
  </code></pre>
  
  <p>Problem:</p>
  
  <p>All of the above works fine, when I try to change the onclick value of the stopButton element:</p>
  
  <pre><code>.Write ("&lt;script language=""javascript""&gt;" &amp; vbcrlf)
  .Write ("var stopButton = opener.document.getElementById(""timerStop"");" &amp; vbcrlf)
  .Write ("stopButton.style.display = ""inline"";" &amp; vbcrlf)
  **.Write ("stopButton.onclick = function () {alert(""test"");};" &amp; vbcrlf)**
  .Write ("window.close();" &amp; vbcrlf)
  .Write ("&lt;/script&gt;" &amp; vbcrlf)
  </code></pre>
  
  <p>And then click on the button after the window closes I get an error in FF and nothing happens in IE:</p>
  
  <blockquote>
    <p>uncaught exception: [Exception...
    "Component returned failure code:
    0x80004005 (NS_ERROR_FAILURE)
    [nsIDOMWindowInternal.alert]"
    nsresult: "0x80004005
    (NS_ERROR_FAILURE)" location: "JS
    frame ::
    /timer/activity_proc.asp?a=start ::
    anonymous :: line 8" data: no]</p>
  </blockquote>
  
  <p>Is this because the child window no longer exists?  I should note that the button does have an onclick value prior to me attempting to change its value.</p>