My question is this: after downloading a file via PHP's header('Content-Disposition: attachment... technique, the webpage that originated the download has a document.readyState value of interactive.
I would expect this to be complete instead, as the downloading is complete.
Am I missing something, or is this the expected behavior?
If the latter, then is there any way to reset the document.readyState back to complete?
(This is using Internet Explorer, if it makes a difference...)
Background:
I have some JavaScript functions that I want active only when the page finishes loading, so I use
if( document.readyState != "complete" ) return;
at their start to achieve this goal. This works properly with the page loading, as document.readyState is interactive while loading progressively, and is complete only upon completion of the page load.
Later in the page, I present a link which sends the user to the below PHP code to allow download of the data loaded:
header( 'Content-Type: text/csv; charset=Shift-JIS' );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
$output = fopen( 'php://output', 'w' );
//write to file output...
fclose( $output );
Now, pressing on this link causes document.readyState to be first loading and then interactive, but the state stays there, never moving to complete, thus disabling the earlier JavaScript functions...
I am at a loss of why this is so, and would appreciate any help, in any direction.