title: Why is my table is not displaying when I write it 'onload'?
body: <p>Something really weird is happening, it works when I <code>document.write()</code> outside the <code>window.onload = function(){}</code> But It doesn't when I call it from inside. Please note, the table is created (I can tell because I see the source).</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
  &lt;title&gt;title&lt;/title&gt;
  &lt;style type="text/css"&gt;
  #chessboard{margin:0;padding:0;border:2px solid #000}
  #chessboard td{margin:0;padding:0;height:44px;width:42px;border:1px solid #000;background-repeat:no-repeat}
  #chessboard td.ws{background-color:#ddd}
  #chessboard td.bs{background-color:#999}
  #chessboard td.bp{background-image:url('./pieces/bp.png')}
  #chessboard td.br{background-image:url('./pieces/br.png')}
  #chessboard td.bn{background-image:url('./pieces/bn.png')}
  #chessboard td.bb{background-image:url('./pieces/bb.png')}
  #chessboard td.bq{background-image:url('./pieces/bq.png')}
  #chessboard td.bk{background-image:url('./pieces/bk.png')}
  #chessboard td.wp{background-image:url('./pieces/wp.png')}
  #chessboard td.wr{background-image:url('./pieces/wr.png')}
  #chessboard td.wn{background-image:url('./pieces/wn.png')}
  #chessboard td.wb{background-image:url('./pieces/wb.png')}
  #chessboard td.wq{background-image:url('./pieces/wq.png')}
  #chessboard td.wk{background-image:url('./pieces/wk.png')}
  
  &lt;/style&gt;
  &lt;script type="text/javascript"&gt;
  var map="",i,ii,wsbs=true;
  var abc=["a","b","c","d","e","f","g","h"];
  
  map+="&lt;div align=\"center\"&gt;&lt;table id=\"chessboard\" cellpadding=\"0\" cellspacing=\"0\"&gt;&lt;tbody&gt;";
  for(i=8;i&gt;0;i--){
  map+="&lt;tr&gt;";
  for(ii=0;ii&lt;8;ii++){
  map+="&lt;td id=\""+abc[ii]+""+i+"\" class=\"";
  if(wsbs==true)map+="ws";else map+="bs";
  map+="\"&gt;&amp;nbsp;&lt;/td&gt;";
  if(ii!=7)wsbs=!wsbs;
  }
  map+="&lt;/tr&gt;";
  }
  map+="&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;";
  
  //document.write(map); works here
  
  window.onload = function(){
  document.write(map);
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>