See: http://developer.yahoo.com/yui/3/event/#onavailable. Then any movement of the mouse at that point will push the script one last time. Note that this will not work in IE 8 and lower. By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. I really like the YUI3 library for this sort of thing. Another way to do this is by using event listeners, here how you use them: DOMContentLoaded It means when the DOM Objects of the document are fully loaded and seen by JavaScript, also this could have been "click", "focus"... function() Anonymous function, will be invoked when the event occurs. How does the highlight.js change affect Stack Overflow specifically? Please find below code that shows my problem scenario. Become a member today and access the collective knowledge of thousands of technology experts. This should give you a popup on page load to confirm that the script is working. Throw this link out here for anyone that comes across this answer, This answer is no longer relevant. Since the onload event is only supported on a few elements, you have to use an alternate method. Why aren't apps like Gradle, Carbon Copy Cloner, Android Studio, etc. If yes, does the order in which they're written matter? Selling space. if (previousOnload) { How should I tell manager? Questions: How can I assign color to the mouse cursor in a web-page? Try this one too. Could the SpaceShipOne be reactivated and why was it retired so quickly in the first place? As all said, you cannot use onLoad event on a DIV instead but it before body tag. November 13, 2017 When the page has loaded, I want to run some JavaScript code to dynamically populate portions of the page with data from the server. I just want to add here that if any one want to call a function on load event of div & you don't want to use jQuery(due to conflict as in my case) then simply call a function after all the html code or any other code you have written including the function code and @epascarello: Good catch, fixed, you see a habit when writing function names. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. we can use MutationObserver to solve the problem in efficient way adding a sample code below. but in case you have one footer file and include it in many pages. 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.. or let's say preload its functions or whatever.. sometimes a person ask questions because he don't know at all, but it's never the case where someone would spoon feed you, nor anyone in this community would, you have to look up stuff yourself a little bit more. I can build on @JohnWilliams' hack (on this page, from 2017) - which is, so far, the best approach I have come across. Why. Employer planning on making a change that I'm prepared to quit over. And never use trigger twice on div! Why is social engineering often exluded from bug bounties? I thought the answer might be document.currentScript, but this is not universally supported. Last time I've checked mutation events performed terribly. A