brianlange Posted April 26, 2012 Share Posted April 26, 2012 I have a complicated php page with javascript. It was having issue loading. I moved the body onload to window.onload and the page is working better. My boss seems to think this should be irrelevant but after 20 tests it appears to make a difference. Has anyone had a similar issue? I know I am being vague and I cannot post code, I was just looking for comments on issues with using the onload body property. Quote Link to comment https://forums.phpfreaks.com/topic/261664-body-onload-to-windowonload/ Share on other sites More sharing options...
requinix Posted April 26, 2012 Share Posted April 26, 2012 Being vague and saying things like "issue loading" and "make a difference" really doesn't help us understand what you're talking about. Or what we're supposed to do. Do you want anecdotes about using the onload event? Something more helpful? Quote Link to comment https://forums.phpfreaks.com/topic/261664-body-onload-to-windowonload/#findComment-1340847 Share on other sites More sharing options...
Jessica Posted April 26, 2012 Share Posted April 26, 2012 To be fair, he does acknowledge that he's being vague and asking for anectada Quote Link to comment https://forums.phpfreaks.com/topic/261664-body-onload-to-windowonload/#findComment-1340854 Share on other sites More sharing options...
rythemton Posted April 26, 2012 Share Posted April 26, 2012 If I had to guess at what is being asked, it seems like he is asking if there is a difference between: <body onload="myfunction();"> and: <script type="javascript"> window.onload=myfunction; </script> I personally haven't experienced any difference. I usually like to use the window.onload method so that I don't have to add anything more than I have to for the HTML code. Quote Link to comment https://forums.phpfreaks.com/topic/261664-body-onload-to-windowonload/#findComment-1340901 Share on other sites More sharing options...
haku Posted April 28, 2012 Share Posted April 28, 2012 body onload was the way things were done in the early days of the internet, but markup (html), display (css), and function (javascript) are meant to be kept separate now. window.onload allows for onload functions to be kept in an external file, allowing for this separation. That alone is enough of a reason to be using it. Quote Link to comment https://forums.phpfreaks.com/topic/261664-body-onload-to-windowonload/#findComment-1341281 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.