2011-04-22 54 views

回答

6

你可以把一個內嵌腳本調用你的函數或者執行文件中。從邏輯上講,它應該呈現在哪裏。

<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> 
+0

在此示例中,腳本在第一個div完全呈現時執行。從邏輯上講,它是下一個要執行的塊,所以在其他答案中詳細說明,不需要事件。 – daganh 2011-04-22 23:22:19

1

沒有事件,只要創建一個回調函數,在html寫入完成後,調用你的回調函數。

function x (html, callback) { 
    divElement.innerHTML = html; 
    callback(); 
} 
1

我認爲你需要像這樣:

<!-- This is the Div to be rendered: --> 
<div> 

<script> 
     /* This script is executed when all div is rendered!!*/ 

</script> 

</div>