Using document.readyState instead of onload.