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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.