Philipp 7, 5 5 gold badges 51 51 silver badges 58 58 bronze badges. Sarfraz Sarfraz k 70 70 gold badges silver badges bronze badges. This is not correct, the function will execute and assign whatever it returns to onload. The should not be there. If there are other functions that are listening for the onload event this will blow them away.
Better to add an event listener rather than assign an event handler directly. Your way seeks to execute yourfunction at the time of the assignment. Thanks — Sarfraz. Show 1 more comment. I think his answer is clear, as you can see the script is put in the head tag thus allowing it to be executed before the body content..
Abhishek Abhishek 6 6 silver badges 9 9 bronze badges. I think this is not a code obfuscation contest. It's unclear, therefore useless. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked 0. See more linked questions.
Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings. No votes so far! Be the first to rate this post. Primary Primary. Skip to content. Using JavaScript In pure JavaScript, the standard method to detect a fully loaded page is using the onload event handler property.
Rate this post. We are sorry that this post was not useful for you! Tell us how we can improve this post? Submit Feedback. If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:. Properties: constructor global ignoreCase lastIndex multiline source Methods: compile exec test toString. In JavaScript: object. In JavaScript, using the addEventListener method: object. Report Error.
Your message has been sent to W3Schools.
0コメント