I don't do much PHP I'm trying to accomplish something I do in C#. I want to have a small piece of text load as soon as the page loads, at that point the code starts working, this can take up to a minute. When finished I want the text to go away (or possibly be replaced.) Is there a "Label" control in php so that when the page first starts to display this label will show? is so, is there a way I can then make it invisible in the code? as an example when you go to http://websiteanalysis.topwebsitetips.com/results/affiliatemarketerguide.com. You will see the text "It can take up to 1 minute to collect the Analysis Information" when the page first loads, with nothing else on the page. When the page completes in a minute or so, I want that text to go away.
Javascript + Iframe, check this site for the code: http://www.tipstrs.com/tip/3126/Telling-when-an-iframe-is-done-loading when the page has finished loading you can have javascript hide the label, and display only the iframe
interesting idea, but what code will make the frame go away. I suppose I could set it to a 0 height and width, but there isn't an attribute that makes it invisible. I don't want any of the data in an iframe, only the text that will eventually go away.
You can load the data in an iframe with the width and height set to 0 and set the style to display:none, when it has finished loading use the .innerHTML to replace the body of the page. example: <html> <head> <script type="text/javascript"> function swapme(){ document.body.innerHTML = window.frames['test'].document.body.innerHTML } </script> </head> <body> <h2>Please wait while we load your results</h2> <iframe id="test" name="test" src="test.html" onload="swapme();" width="0" height="0" style="display:none;"></iframe> </body> </html> Code (markup):
I've been working on a disappear version. but can't seem to get it to work. any idea why? Code in head <script type="text/javascript"> function remove() { // Check if loading is complete if ( iframe.document.readyState == 'complete' ) { // The loading is complete, call the function we want executed once the iframe is loaded var elem = document.getElementById('waitIframe'); var old = (elem.parentNode).removeChild(elem); return; } // If we are here, it is not loaded. Set things up so we check the status again in 100 milliseconds window.setTimeout('remove();', 100); } </script> Code (markup): Code in body <iframe id="waitIframe" onload="remove();" width="450px" height="30px" scrolling="no" src="pleasewait.htm"></iframe> Code (markup):
It doesn't work backwards. The only way to display the message is to have it already present, and then load your data. It won't work the other way around because the script won't run until the page has loaded. And php won't send the page until it has finished.