how to check if page is loaded first time in javascript
a web page has completely loaded all content (including images, script files, as in example? If on-load flag not exist create it - this is first load. Would the reflected sun's radiation melt ice in LEO? Naturally, unload event is when the user leaves us, and wed like to save the data on our server. Find centralized, trusted content and collaborate around the technologies you use most. window.onload on the other hand will over-write them. Comment deleted! By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. @epascarello, no it isn't and according to the specs you can test if back button was clicked, not the refresh button. It begins as soon as the resource is loaded. CSS3 Transitions: replace them entirely on mobile? Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Polling is the best way if I dont know when my script is being injected. Firefox, Chrome and Opera autofill forms on DOMContentLoaded. Browse other questions tagged, Start here for a quick overview of the site, Detailed answers to any questions you might have, Discuss the workings and policies of this site. If dark matter was created in the early universe and its formation released energy, is there any evidence of that energy in the cmb? Your query can be solved easily by this helpful link: OnLoad W3School If you want loading status: You can do that using simple Javascript if (document.readyState == "complete") { alert ("Your page is loaded"); } Return Value: A String, representing the status of the current document. It will run the function as soon as the webpage has been loaded. If you don't know how to use javascript, I would recommend reading through some tutorials first. Using polling here seems a bit crude in comparison to replacing it with listening for a readystatechange event. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Learn more about Stack Overflow the company, and our products. This method should be execute only after refresh, not after 1st page-load. Thats a precaution, as scripts may want to modify DOM, and even document.write into it, so DOMContentLoaded has to wait. Can you use a cookie? This standard say the first point has to be that "interactive" fires precisely after dom parsed! ((window.performance.timing.domComplete- window.performance.timing.navigationStart)/1000)+" sec. ,