Behavior observed on 14.0.835.202. Edit : (on Windows Seven x64).
Behavior observed on 14.0.835.202. Edit : (on Windows Seven x64) It's not the jquery fault : The DOMContentLoaded is fired another time just before page unload. Simple test to check this : function startpage() { console.
Log('page loaded'); } function unloadPage(){ console. Log("page unloaded"); } document. AddEventListener("DOMContentLoaded", startpage, false); window.
Onbeforeunload = unloadPage; You should see after a refresh: page loaded page loaded // should not be here and is not on Firefox. Page unloaded loaded In your console (with persistence on) I think it's simply a Chrome bug. Not a console one, as timestamping proves it's not a duplicate.
Edit : the same Chrome version but running OSX seems ok (see comment below). It tends to confirm that it's a bug.
1 Tested on Chrome 14.0.835.202 on OSX 10.6.7 and could not recreate bug. Log reads as expected, page loaded; page unloaded; for each request cycle. – Daniel Mendel Oct 25 '11 at 13:49 Thanks for your input!
So the OSX version seems OK. I did not mention my OS : my test was on Windows Seven x64. I will run the test on Windows XP (x86) when I have some time.
– mdi Oct 25 '11 at 13:50 1 The issue does occur on OSX - that's what I'm using – asgeo1 Oct 26 '11 at 9:22.
In Chrome 13 for Mac I am not seeing this behavior. After you load the page for the first time, and before you hit refresh, do you clear out the console? Is there a chance you are seeing the old console output (I know some browsers like to keep a previous page's console output around)?
I would not expect those two events to be fired twice on a refresh, so my guess would be stale console, either by design because it was a manual refresh or perhaps Chrome 14 has bugs with their dev console.
I just did an additional test to rule out missunderstanding of the console output. I created a random number that I included in the output, and the test shows for sure that the first 4 outputs are from initial load of page and then just before page has been reloaded (when I release refresh button). So the methods are called when leaving page after a reload.
– Sten Aug 29 '11 at 6:08.
As far as I know, clicking an #xxx link (or link to the same page, with or without #xxx) does not trigger window. Load and document. Ready events.
If you want the link to trigger an event, do something like $('a#xxx'). Click(function(){ //Your code here } where xxx is the ID of the link. If the link was meant to reload the page, use window.location.reload() in the click event handler.
I do not want the extra calls to take place. The extra calls are the problem and the link I added was just to see if the errenous calls were made on link click too. (They are not) – Sten Aug 29 '11 at 6:11.
I have tested this on Chromium 14 on Windows. Behavior is not observed.
It seems like a chrome/webkit developer console bug. Using chrome 14 on Ubuntu I can reproduce the bug by following the next steps. First create a page containing the following js code var timesLoaded = 0; function loadHandler() { console.
Log(timesLoaded, "times loaded"); timesLoaded++; } function unloadHandler(){ console. Log("unload after ", timesLoaded, " loads"); } $(document). Ready(loadHandler); $(window).
Unload(unloadHandler); Open the page with google chrome Press F12 to open the console and see the 0 "times loaded" message Add a breakpoint on the first line of the unloadHandler function To see the double message appear you should click somewhere on the page (like giving focus out of the console and to the loaded page) Refresh the page You will probably see the 0 "times loaded" message again The important thing is that your code is not executed twice. Its just that for some reason the webkit dev console displays the same message again. To further investigate the bug you can do the following, Load the previous html page Add the unload breakpoint again (just to be sure the page will not actually refresh) Right click on the console first entry (0 "times loaded") Click inspect element (yes console is just an html/js app) Locate the element the entry belongs to (it should be a div.
Console-group-message element Right click on the element and click on Break on Subtree Modifications Refresh the page (again after clicking somewhere on the html page to unfocus console window Just before the second annoying message appears the debugger will show up to the console code that tries to append the message.
Just to add some notes on testing, using chrome 15.0.874.102 and windows 7 x86: This is the script I used for testing from my understanding of the question: Testing Chrome Reload Page The following is a cumulative log, each new addition highlighted in bold: On initial page load I get: ---Loaded. ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) Pressing F5 whilst focused on the HTML page: ---Loaded. ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) ---Loaded.ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) ---Loaded.
ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) Un-loaded. ID: 68 Time: Tue Oct 25 2011 21:36:12 GMT+0100 (GMT Daylight Time) ---Loaded.ID: 78 Time: Tue Oct 25 2011 21:36:12 GMT+0100 (GMT Daylight Time) ----Reload Link---- Un-loaded. ID: 78 Time: Tue Oct 25 2011 21:38:25 GMT+0100 (GMT Daylight Time) ---Loaded.
ID: 22 Time: Tue Oct 25 2011 21:38:25 GMT+0100 (GMT Daylight Time) Pressing F5 whilst focused on the console: ---Loaded.ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) ---Loaded. ID: 68 Time: Tue Oct 25 2011 21:35:18 GMT+0100 (GMT Daylight Time) Un-loaded. ID: 68 Time: Tue Oct 25 2011 21:36:12 GMT+0100 (GMT Daylight Time) ---Loaded.ID: 78 Time: Tue Oct 25 2011 21:36:12 GMT+0100 (GMT Daylight Time) ----Reload Link---- Un-loaded.
ID: 78 Time: Tue Oct 25 2011 21:38:25 GMT+0100 (GMT Daylight Time) ---Loaded. ID: 22 Time: Tue Oct 25 2011 21:38:25 GMT+0100 (GMT Daylight Time) Un-loaded.ID: 22 Time: Tue Oct 25 2011 21:41:53 GMT+0100 (GMT Daylight Time) ---Loaded. ID: 15 Time: Tue Oct 25 2011 21:41:54 GMT+0100 (GMT Daylight Time) As you can see the anomaly only occurs when directly reloading the page (I have highlighted the anomaly with an arrow), whilst focused on the page itself.
Also, if you notice both the ID and the timestamp of the anomaly they are the same even after waiting several seconds before hitting F5 - so it appears the code isn't running for a second time so to speak, but the console is logging a copy for some reason. Adding further to the conclusion: If you select the timeline tab, and record both an initial page load, and an F5 reload, you will notice the two functions to write to the console are only run once, further compounding it looks like a possible error on chromes console: Show Image - Timeline 1 (initial load) Show Image - Timeline 2 (F5 reload).
Thanks mate. There were some other pretty good explanations of the issue, but since I have to pick one this was the most detailed explanation so it gets it. Cheers – asgeo1 Oct 26 '11 at 9:28.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.