Javascript: Dynamically Change onclick Event
Brief summary of how to properly add an event in javascript dynamically.
To dynamically change or add an “onclick” event handler to an element, try:
var el = document.getElementById('foo');
el.onclick = showPopup;
//NOTE: showPopup();
//or showPopup(param);
//will NOT work here.
//Must be a reference to a function,
//not a function call.
function showPopup() {
var popup = window.open(this.href, "popup", "height=800,width=600");
popup.focus();
return false;
}



















