I have heard many times that using JavaScript events, such as onClick()
, in HTML is a bad practice, because it\'s not good for semantics. I would like to know w
It's not good for several reasons:
eval
The simplest thing would be to add a name
attribute to your element, then you could do:
document.myelement.onclick = function() {
window.popup('/map/', 300, 300, 'map');
return false;
};
although modern best practise would be to use an id
instead of a name, and use addEventListener()
instead of using onclick
since that allows you to bind multiple functions to a single event.