MichaelMackey Posted June 6, 2008 Share Posted June 6, 2008 So I have a hard time figuring out what javascript is doing sometimes. Right now I'm a little confused on why it reacts this way to a page load event. Here's what I have, fairly simple: window.location = "ad_index.php?kn_mod=inst_res&done=yes"; window.onload = loadEmailPage(emails); function loadEmailPage(emails){ document.getElementById('shortList').value = emails; } The funny thing is this will work if an alert goes off before the changing of the values. I just don't get why it wont work without the alert. Thanks Link to comment https://forums.phpfreaks.com/topic/109028-page-load-issue/ Share on other sites More sharing options...
mrdamien Posted June 7, 2008 Share Posted June 7, 2008 When you say window.location = 'etc'; your navigating away from your page, meaning your current page might not load completely, meaning that window.onload never gets triggered. Link to comment https://forums.phpfreaks.com/topic/109028-page-load-issue/#findComment-560122 Share on other sites More sharing options...
hansford Posted June 8, 2008 Share Posted June 8, 2008 The former commenter is correct. A page needs time to load. when you put the alert in there it gives it that extra time needed to run the onload event. if this function needs to run before the window.location then just call the function before. Link to comment https://forums.phpfreaks.com/topic/109028-page-load-issue/#findComment-560129 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.