To implement an OnClick event dynamically you need to add this event to the DOM object with addEventListener
as in the @SilvioAndorinha response, however this implementation is different in other browsers so you can use a function to do this cross- browser.
Your Role
function buscaImagem(){
alert("teste do onclick")
}
Javascript addEvent cross-browser
var addEvent = function(elem, type, eventHandle) {
if (elem == null || typeof(elem) == 'undefined') return;
if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle, false );
} else if ( elem.attachEvent ) {
elem.attachEvent( "on" + type, eventHandle );
} else {
elem["on"+type]=eventHandle;
}
};
addEvent(document.getElementById("btSoyouzm"), "click", function(){
buscaImagem();
});
or
addEvent(document.getElementById("btSoyouzm"), "click",buscaImagem);