Attach onload event rather than window.onload