function show(url,width,height) { var str = '<div id="pu" style="display: block; width: 200px;">'; str +='<img border="0" src="'+url+'" width="'+width+'" height="'+height+'" alt="" />'; str += '</div>'; document.getElementById('id_elementu_do_ktorego_chcesz_wstawic_ten_kod').innerHTML += str; // jezeli element nie ma id, no to musisz dostać uchwyt tego elementu. //U ciebie domyślam się ze chodzi o body document.body.innerHTML += str; }