最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - DIV: Completely rendered indicator event- Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a ment  | 

3 Answers 3

Reset to default 6

You 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>
发布评论

评论列表(0)

  1. 暂无评论