Norin Posted May 9, 2007 Share Posted May 9, 2007 Hello, I'd like to add a Loading screen to my web site but the problem is that this loading screen must appear BEFORE the page actually load. When I open my site, it says "Waiting for localhost..." then everything appears really fast, so all the loading scripts I found are not working since they get activated while the page is loaded, which is really fast. I'd like the loading to show when it says "Waiting for localhost..." I tried to make a php file to redirect to my page but showing "Loading..." but I did not got it working. Thanks Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/ Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 You could use a meta redirect and set the redirect time to be like 10 seconds, that way the page is always displayed for 10 seconds before being redirected? Maybe I am unclear on what you are really asking for/wanting??? You might also try the sleep() function www.php.net/sleep Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249197 Share on other sites More sharing options...
Norin Posted May 9, 2007 Author Share Posted May 9, 2007 well, if I could simply "prepare" the page while displaying a message THEN display the page when it is ready, it would be perfect Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249201 Share on other sites More sharing options...
trq Posted May 9, 2007 Share Posted May 9, 2007 your really looking for an Ajax solution here. PHP allone has no way of knowing when your page has loaded, this all happens client side. Honestly, if your page is taking that long to load that it needs a 'loading...' page, something is seriously wrong. Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249205 Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 You could use buffering www.php.net/ob_start www.php.net/ob_end_clean www.php.net/ob_get_contents example: <?php echo 'Page is loading please wait...<br />'; ob_start(); echo 'This is echoed in the buffer portion. <br />'; for ($i=0;$i<50000; $i++) { echo $i . ' time<br />'; } echo 'This is the end of the buffer section'; $output = ob_get_contents(); ob_end_clean(); echo 'The output is read <br />'; echo $output; ?> Now this in coordination with div tags and javascript you can have it dynamically remove the page loading etc. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249206 Share on other sites More sharing options...
Trium918 Posted May 9, 2007 Share Posted May 9, 2007 frost110 how did you learn PHP and how long have you been using it and your age? Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249210 Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 www.php.net My best learning source. Never read any books, I found them very disappointingly stupid. I started with Javascript than moved to php. Perhaps the biggest push was a friend asked me to create a movie webfetch. From there he asked me to modify some blog code and yea. Programming came pretty easy. I am 22, been programming since I was 13. Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249212 Share on other sites More sharing options...
Trium918 Posted May 9, 2007 Share Posted May 9, 2007 I just started last year and I am only 23. Man, you have some experience under your belt. Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249216 Share on other sites More sharing options...
Norin Posted May 9, 2007 Author Share Posted May 9, 2007 You could use buffering www.php.net/ob_start www.php.net/ob_end_clean www.php.net/ob_get_contents example: <?php echo 'Page is loading please wait...<br />'; ob_start(); echo 'This is echoed in the buffer portion. <br />'; for ($i=0;$i<50000; $i++) { echo $i . ' time<br />'; } echo 'This is the end of the buffer section'; $output = ob_get_contents(); ob_end_clean(); echo 'The output is read <br />'; echo $output; ?> Now this in coordination with div tags and javascript you can have it dynamically remove the page loading etc. Hope this helps. Your code does what I would like to do but instead of having a numbers of times a number is shown, I'd like it to include a page. I tried to replace the "for" with my "include" but it does not work... It just waits untill it has loaded everything THEN it shows everything in one block. Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249218 Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 <?php echo 'Page is loading please wait...<br />'; ob_start(); echo 'This is echoed in the buffer portion. <br />'; include('yourfile.php'); echo 'This is the end of the buffer section'; $output = ob_get_contents(); ob_end_clean(); echo 'The output is read <br />'; echo $output; ?> Try that maybe? Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249230 Share on other sites More sharing options...
Norin Posted May 9, 2007 Author Share Posted May 9, 2007 Nope, thats the code I was using :-\ I dont know if it has something to do with my use of tinybutstrong in the file... [templates using many blocks then ONE show] Link to comment https://forums.phpfreaks.com/topic/50691-php-loading/#findComment-249241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.