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 Quote 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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/109028-page-load-issue/#findComment-560129 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.