onlycode.org

javascript
jquery
html
css
angularjs
node.js
ajax
html5
php
json
arrays
google-chrome
dom
regex
reactjs
ecmascript-6
javascript-events

your's history:
window onload vs documen...

window.onload vs document.onload, just only code

javascript | javascript-events

edit
$(document).ready(function() { /* code here */ });
$(function() { /* code here */ });

31
Leigh, 25.02.2009 23:46




edit
<script language="javascript">
window.tdiff = []; fred = function(a,b){return a-b;};
window.document.onload = function(e){ 
    console.log("document.onload", e, Date.now() ,window.tdiff,  
    (window.tdiff[0] = Date.now()) && window.tdiff.reduce(fred) ); 
}
window.onload = function(e){ 
    console.log("window.onload", e, Date.now() ,window.tdiff, 
    (window.tdiff[1] = Date.now()) && window.tdiff.reduce(fred) ); 
}
</script>

30
Lorenz Lo Sauer, 10.09.2011 15:05




edit
<script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function(event) {
      // - Code to execute when all DOM content is loaded. 
      // - including fonts, images, etc.
  });
</script>
window.addEventListener('load', function() {
    console.log('All assets are loaded')
})
$(window).on('load', function() {
    console.log('All assets are loaded')
})

28
Paul Chu, 28.06.2016 14:57



edit
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <!--import css here-->
        <!--import js scripts here-->

        <script language="javascript">

            function bodyOnloadHandler() {
                console.log("body onload");
            }

            window.onload = function(e) {
                console.log("window loaded");
            };
        </script>
    </head>

    <body onload="bodyOnloadHandler()">

        Page contents go here.

    </body>
</html>

12
VincentZHANG, 26.01.2015 06:08

Add your just only code

your name:    



If you need full text click here

Some similar links window.onload vs document.onload ↓:
window.onload vs <body onload=“”/>

window.onload vs $(document).ready()

Detecting the onload event of a window opened with window.open

when is window.onload fired



This project is created for those who just need only code, wihout maaaaaaaaaaany words.