Event callbacks assigned through onevent attributes in innerHTML and outerHTML statements

When you use innerHTML or outerHTML to add elements to the DOM of a document, any event callbacks assigned within the statement, such as onclick or onmouseover, are ignored. No security error is generated. Instead, you can assign an id attribute to the new elements and set the event handler callback functions using the addEventListener() method.

For example, given a target element in a document, such as:

<div id="container"></div>

Replace statements such as:

document.getElementById('container').innerHTML =
    '<a href="#" onclick="code()">Click Me</a>';

with:

document.getElementById('container').innerHTML = '<a href="#" id="smith">Click Me</a>';
smith = document.getElementById('smith');
if(smith!=null) smith.addEventListener("click", function() { code(); });

by Help Adobe