Switch to jquery. .ready instead of window.onload should work as I originally intended