Flames Posted October 2, 2008 Share Posted October 2, 2008 sometimes when you go on websites or certain forums e.g. vbforums when you log in it goes to a page where it says loading or redirecting, whats the point of using these and is it neccessary because i thought pages are instant? if it is how do you make a page loading and then when its loaded show the page? note: im not sure this is javascript im just taking a guess. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 2, 2008 Share Posted October 2, 2008 Pages don't load instantly. They take time. Sometimes milliseconds, sometimes seconds, sometimes minutes, depending on page complexity and user connection speed. Now, there is a way to do this using JS. I do it all the time. Use the body's onload event to remove your "loading" tag. The onload event occurs when the page is finished loading. Let me know if you want an example. Also, there are two different things you can do. You can either display a loading tag or image above the page you're loading, OR you can hide the rest of the page and ONLY display the loading tag. If you want an example, let me know which you want. Quote Link to comment Share on other sites More sharing options...
Flames Posted October 2, 2008 Author Share Posted October 2, 2008 Well, i would like to know and see examples for both methods, but also could you tell me generally what sort of pages need loading scripts? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 2, 2008 Share Posted October 2, 2008 No page "needs" a loading script. It is just personal preference. On some pages, personally, I like my users to see a "Please wait" message if it's a particularly complicated page and I expect it to take a minute or so to load. Do you want one? If you don't, don't bother. If you do, I'll show you one. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted October 2, 2008 Share Posted October 2, 2008 The OP's topic is regarding redirection. Forums like vbforums/phpbb, direct you to a login page for processing, and then redirect you to your destination, such as the board index. I'm not sure what they are doing on that page, but the 'loading' message isn't really loading anything, it's just letting the user know that something happened, and to wait for the redirect (or usually they have a link to click for impatient people like me). Maybe it's because some people get confused when they see their browser going from index.php->login.php->somethingelse.php with them only clicking one thing... who knows. But I would say that this is about redirection, not actual content loading. examples to cause redirection: //don't show anything, just move from that page right away //PHP <?php header('Location: page.php'); ?> //redirect after X seconds; to url //html <meta http-equiv="refresh" content="1;URL=http://www.google.com/" /> //redirect (right away) //javascript <script type="text/javascript">window.location="http://someplace.com";</script> Quote Link to comment Share on other sites More sharing options...
Flames Posted October 3, 2008 Author Share Posted October 3, 2008 So if i make a loading script, could i just include it at the top of every page, and does a loading script automatically dissappear once the page is fully loaded? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 3, 2008 Share Posted October 3, 2008 OK, if you just want a "Loading" script, try something like this: Add this to your HEAD section: <script type="text/javascript"> function onlyHide(id) { document.getElementById(id).style.display = "none"; } </script> Add this to the top of your BODY section: <body onload="onlyHide('pleasewait');"> <table width="100%" height="100%" cellpadding="5" id="pleasewait" style="display:block;z-index:1;position:absolute;left:0px;top:0px;"> <tr height="225"> <td width="100%" colspan="3"> </td> </tr> <tr> <td width="49%"> </td> <td align="center" valign="middle" width="2%" nowrap bgcolor="#FFFFFF" style="border: solid 1px black;"> Please wait...<br> <image src="images/pleasewait.gif"> </td> <td width="49%"> </td> </tr> </table> <!-- Add the rest of your page here --> [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Flames Posted October 3, 2008 Author Share Posted October 3, 2008 Thanks for the code, i did try it but it seemed to crash due to my quite badly made site layout. Hopefully my friend will have finished a new design for the website so ill try it then, although it might have been because i put the head part as loadingheader.php and put the body part as loadingbody.php and used includes i got the main box but there was a problem where the box would appear in the main iframe and not dissappear. Ill try after the weekend and tell you how it goes after wards. Site Layout |-------------------| |Main Title | |-------------------| |Nav Bar | |-------------------| | | | Main iframe | |-------------------| Flames! 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.