Add variable inside of a function
<p>I have the following code</p>

<pre><code>var elements = parent.document.getElementsByTagName('a');
for(var i = 0, len = elements.length; i &lt; len; i++) {
  elements[i].onclick = function () {
   return confirm_exit('".$_SESSION['SES_abr_langue']."');
  }
}
</code></pre>

<p>And I need for the onclick to be appended to the existing onclick event, if it exists.</p>

<p>When I add <code>elements[i].onclick</code> inside the function() it just "hardcodes" it. Meaning it literally puts elements[i].onclick instead of the value of the onclick.</p>

<p>Thanks!</p>
