Sorry that it took a bit! I needed time to come up with a proper test case.
The steps you show are correct for a normal page load process. Example code attached:
main.html:
<script src="log.js"></script>
<iframe src="iframe1.html"></iframe>
iframe1.html:
<script src="log.js"></script>
<a href="iframe2.html">iframe2</a>
iframe2.html:
<script src="log.js"></script>
log.js:
function log(evt) {
console.log(evt.target.URL + ": " + evt.type);
}
function processReadyStateChange(evt) {
console.log(evt.target.URL + " readyState: " + document.readyState);
}
window.addEventListener("load", log);
window.addEventListener("pagehide", log);
window.addEventListener("beforeunload", log);
window.addEventListener("unload", log);
window.addEventListener("pageshow", log);
document.addEventListener("readystatechange", processReadyStateChange);
The difference is when you access another page. In my test case I 1) cleared the console log 2) reloaded the page 3) clicked the link within the iframe 4) navigated to
https://mozilla.org.
Result in Firefox:
main.html: beforeunload main.html: beforeunload
iframe1.html: beforeunload iframe1.html: beforeunload
main.html: pagehide main.html: pagehide
main.html: unload main.html: unload
iframe1.html: pagehide iframe1.html: pagehide
iframe1.html: unload iframe1.html: unload
main.html readyState: interactive main.html readyState: interactive
iframe1.html readyState: interactive iframe1.html readyState: interactive
iframe1.html readyState: complete iframe1.html readyState: complete
iframe1.html: load iframe1.html: load
iframe1.html: pageshow iframe1.html: pageshow
main.html readyState: complete main.html readyState: complete
main.html: load main.html: load
main.html: pageshow main.html: pageshow
iframe1.html: beforeunload iframe1.html: beforeunload
iframe1.html: pagehide iframe1.html: pagehide
iframe1.html: unload iframe1.html: unload
iframe2.html readyState: interactive iframe2.html readyState: interactive
iframe2.html readyState: complete iframe2.html readyState: complete
iframe2.html: load iframe2.html: load
iframe2.html: pageshow iframe2.html: pageshow
main.html: beforeunload main.html: beforeunload
iframe2.html: beforeunload iframe2.html: beforeunload
main.html: pagehide
main.html: unload
iframe2.html: pagehide
iframe2.html: unload
That means Chrome does not send the 'unload' and 'pagehide' event when navigating to another domain.
So, I suggest to add a browser compatibility section explaining the differences in a footnote.
Sebastian
On Friday, May 13, 2016 at 6:22:05 PM UTC+2, Adi Prasetyo wrote:
> Sorry sir, my bad forget add the function parameter.
> I am not sure about the persistence logs, and how it affect the behavior.
> I already make the sequence, and test it both chrome and FF like so :
>
> i see same sequence on FF and chrome, CMIIW.
> is it necessary to add on the documentation?
>
>
>
> On 13 May 2016 at 15:38, Sebastian Zartner