Jump to content

The use of page loading?


Flames

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.