<div id="Mydiv">anything</div>
<script>
function test(x){alert(x)};
var col=document.getElementById('Mydiv');
col.innerHTML='<div onclick="alert(2);test(123);">Text</div>';
</script>
notes:
1-alert(2); works , but test(123) not working , test(44) is working(outside innerHTML)
2- i want to use parameters inside test() functions i.e: test(123)
You can't rely on JavaScript added inside of innerHTML always running correctly across all browsers - Internet Explorer in particular has many restrictions on how and where innerHTML can be used. If you want the HTML to be able to be properly accessed from JavaScript you should add it using DOM mcalls instead of innerHTML.