Jump to content

redirecting user whilst processing information


daydreamer

Recommended Posts

On a site I am making a user inputs details, submits them and then I do some processing via php.

 

Problem is processing takes about 5-10 seconds. this is a long time for a user to be waiting looking at the same page not being able to do anything.

 

So, can i redirect them to another useful page of my site, while i process the information they gave me on the server?

 

You could add a div that covers the whole page onunload (javascript) on your submitting page. If it's the second page, have it display by default at first, then add an onload function that removes it when the page is done loading.

Why go to all that trouble for 10 seconds? I'd just have a nice animated gif ...processing.... so they can see something's happening.

 

Only other thing I can think of is do what F1Fan said, use a bit of javascript to pop-up a nice overlaying div, keep 'em entertained.

 

Seriously though, are your visitors that edgy?

Here's some code that I use throughout my sites:

 

<script type="text/javascript">
function pleaseWait(){
  document.getElementById('pleasewait').style.display = "none";
}
</script>
<body onload="pleaseWait();">
<table width="100%" height="100%" bgcolor="#FFFFFF" id="pleasewait" style="display:block;z-index:2;position:absolute;left:0px;top:52px;">
<tr height="225">
	<td width="100%" colspan="3">
		 
	</td>
</tr>
<tr>
	<td width="49%">
		 
	</td>
	<td align="center" valign="middle" width="2%" nowrap>
		Please wait...<br>
		<image src="images/pleasewait.gif">
	</td>
	<td width="49%">
		 
	</td>
</tr>
</table>
<!-- rest of your body here -->

 

This code can be easily modified to work on unload. Just replace "onload" with "onunload,"

document.getElementById('pleasewait').style.display = "none";

with

document.getElementById('pleasewait').style.display = "block";

and

<table width="100%" height="100%" bgcolor="#FFFFFF" id="pleasewait" style="display:block;z-index:2;position:absolute;left:0px;top:52px;">

with

<table width="100%" height="100%" bgcolor="#FFFFFF" id="pleasewait" style="display:none;z-index:2;position:absolute;left:0px;top:52px;">

Thanks F1Fan, ill probably end up doing something like that.

 

Damien, i dunno if my visitors will be edgy! , but the main reason i want to send them to another page is to have the whole browsing experience on the site fast. nobody likes to wait.

 

cheers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.