I need to call a javascript function when a div
is fully rendered. But, I am not aware of the right event to use.
Appreciate your help.
I need to call a javascript function when a div
is fully rendered. But, I am not aware of the right event to use.
Appreciate your help.
Share Improve this question edited Apr 25, 2011 at 6:21 Akram Shahda asked Apr 22, 2011 at 22:59 Akram ShahdaAkram Shahda 14.8k5 gold badges47 silver badges67 bronze badges3 Answers
Reset to default 6You could put a script inline within the document that calls your function or executes. Just put it logically where it should be rendered.
<html>
<body>
<div><h1>Wait for it!</h1></div>
<script type="text/javascript">
document.write("<h2>Js process</h2>");
alert("Stopping document process");
</script>
<div><h3>Done!</h3></div>
</body>
</html>
No events, just create a callback function, after the writing of html is finished, call your callback routine.
function x ( html, callback) {
divElement.innerHTML = html;
callback();
}
I think that you need something like this:
<!-- This is the Div to be rendered: -->
<div>
<script>
/* This script is executed when all div is rendered!!*/
</script>
</div>