// 使用 jQuery $(document).ready(function() { /* ... */ }); // shorter jQuery version $(function() { /* ... */ }); // without jQuery (doesn't work in older IEs) document.addEventListener('DOMContentLoaded', function() { // your code goes here }, false);