Please Wait...
page 1 of 1
Published: 17 Dec 2003
Unedited - Community Contributed
Add a splash screen to your process-intensive pages; now updated for Netscape 6 and 7!
by Peter Brunone
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 12254/ 18

a Splash Screen for Websites
(now updated for Netscape 6 and 7!)
Maybe you have a page with delicate scripting and you don't want users to touch anything until it finishes loading, or perhaps your form is processing and you need to make sure they don't panic and run before it finishes. Either way, a splash screen with an "In Progress" indicator would help to calm the frightened users and make life easier for your tech support staff.

    Here, then, we have a succinct little bundle of code that will do just that. To begin, you'll need to add a line to the top of the page in question. The line is this (ASP VBScript):

		Response.Buffer = True

    This instructs the server not to send anything back to the client until (a) the page is finished processing or (b) you use Response.Flush to send it everything so far. Incidentally, this will usually help your page speed as well, since the server doesn't have to switch back and forth between executing the page and sending pieces of it to the browser.

    Here -- preferably between the <HEAD> and </HEAD> tags -- we build the JavaScript that decides which of the two major browsers is calling the page, and henceforth which Document Object Model (DOM) to use. Since the script is performing client-side operations, I have chosen to use client-side detection. See my previous article, Is It Human? for more information on server-side browser detection.

		<SCRIPT LANGUAGE="JavaScript">
		// This script is intended for use with a minimum of Netscape 4 or IE 4.
		// First we detect the browser type
		if(document.getElementById) { // IE 5 and up, NS 6 and up
			var upLevel = true;
		else if(document.layers) { // Netscape 4
			var ns4 = true;
		else if(document.all) { // IE 4
			var ie4 = true;

		function showObject(obj) {
			if (ns4) {
				obj.visibility = "show";
			else if (ie4 || upLevel) { = "visible";
		function hideObject(obj) {
			if (ns4) {
				obj.visibility = "hide";
			if (ie4 || upLevel) { = "hidden";

    Next, we have to build the DHTML that will become our splash screen, just like the ones desktop programmers get to use. For convenience, we'll assign the style attributes inline, but you could of course do this with a style sheet within the HTML <HEAD> element.

  <DIV ID="splashScreen" STYLE="position:absolute;z-index:5;top:30%;left:35%;">
    <TABLE BGCOLOR="#000000" BORDER=1 BORDERCOLOR="#000000" 
          <FONT FACE="Helvetica,Verdana,Arial" SIZE=3 COLOR="#000066">
		  <B>Page Loading.  Please wait...</B></FONT> <BR> 
          <IMG SRC="wait.gif" BORDER=1 WIDTH=75 HEIGHT=15><BR><BR> 

    Style it any way you want; just make sure that the ID attribute is the same name that our client-side JavaScript uses to address the element later on. Just for the record, our splash screen looks like this:

    Page Loading. Please wait...    

    At this point you'll want to send the splash screen to the client while the rest of the page is processed. For this reason it is advisable to put the splashScreen DIV as close to the beginning of the <BODY> as possible, in order to send it out quickly without waiting for the rest of the page. To do this, we send the following ASP command:


    Now comes all the processing and grinding that keeps the user waiting. When we come to the end of the page -- just before the closing </BODY> tag -- we send all the code out with another


...and then add the final JavaScript that turns off the splash screen. You could trigger the hideObject function with an onLoad() event handler in the <BODY> tag instead, but you would still need to build the object references after the splashScreen DIV appears in the code, or the browser would complain that your DIV doesn't exist yet.

		<SCRIPT LANGUAGE="JavaScript">
		if(upLevel) {
			var splash = document.getElementById("splashScreen");
		else if(ns4) {
			var splash = document.splashScreen;
		else if(ie4) {
			var splash = document.all.splashScreen;

    You can download a sample file with all the necessary code here, including the sample progress bar image.

User Comments

Date: 2012-02-13 6:57:22 AM
asp alliance yes office windows xp officials yahoo offers msn messengrs offline pakistna hose whats f.103.block N sc.19.blknnnaz ok yes my
Title: Webmaster Forum   
Name: wc
Date: 2009-08-01 10:35:37 AM
Great piece of code. Simple but works really well. Thanks.
Title: nice   
Name: nice
Date: 2007-12-30 12:12:12 AM
Title: Easiest way to display Please Wait Screen   
Name: dng
Date: 2007-06-01 1:29:59 PM

Good work, you will find more easier method to display Splash Screen

Dotnetguts (DNG)
Title: Mozilla has document.all?   
Name: Peter Brunone
Date: 2006-12-14 9:17:22 PM
Hi Venkat,

I thought only Internet Explorer had document.all in its object model.

I'm afraid I don't know much about Cold Fusion; maybe some google searching will help.
Title: hi Mr. Peter   
Name: joni
Date: 2006-11-12 9:19:56 PM
dear Mr.peter

would you like to send me software about coldfusion ?
i know i am to proud to apply about it but i believe you will replay my mail, thanx

from joni pranch
Title: Found Very Useful   
Name: Mahesh S
Date: 2006-06-20 6:16:48 AM
Thanks Peter indeed a very nice article
Title: ASP.NET?   
Name: Tomas
Date: 2006-05-30 3:14:20 AM
Does anybody know how to use something like this in ASP.NET?

Any reply will be wellcome:
Title: It is simply Great.   
Name: Venkat
Date: 2006-03-08 3:11:49 AM
First of all Thanks to the Author.

The code did work perfectly, but with some minor modifications according to my need.I used the following code to initialize the splash variable...

if ( netscape )
var splash = document.getElementById('splashScreen');
else if ( internetexplerer || other )//other means mozilla
var splash = document.all("splashScreen");

and I used the following code to hide the div. = "hidden";

The above line worked for all the Browsers( didn't use IE4 or NS4)...

Any way great work.
Title: ASPX   
Name: Anoop
Date: 2006-02-13 4:51:28 AM
I'm using ASP.Net and can't get this to work. It is not liking <% Response.Buffer = True %>. Any Ideas?
Title: Good stuff   
Name: Brian
Date: 2005-12-20 9:56:31 PM
This works great. Thank You
Title: Wait   
Name: siddhu
Date: 2005-07-12 2:56:03 AM
Very useful
Title: Script-less Splash Screen   
Name: Rick
Date: 2005-06-21 11:59:27 AM
Hey, I've written a class file in VBScript that uses CSS positioning to generate a processing splash screen without using any client-side script or images. It's very customizable just by using the properties and methods it comes with. Very quick and easy to use, imo. Peter B, if you'd like to host that on this site I'm more than willing to email you a copy. I hate surfing the net for example code and never finding what I'm looking for. So I figure I should give back to the "community". if you'd like a copy of what I've come up with. It's commented with details of how to use it, and certainly it can be customized further. I just made it generic and flexible. Though I only spent a couple of hours on it so I'm sure it's not 100% perfect in the minds of most people. It is executing without errors though :P
Title: Great Article   
Name: J
Date: 2005-06-15 1:13:01 PM
This was just what I was looking for. This should stop people from freaking out when the processing of the page takes sometime. Thanks!
Title: Errors?   
Name: Peter B
Date: 2005-06-13 9:27:28 PM
I don't know what server-side error handling code you're talking about, since there isn't any in the example above. What kind of error are you seeing? I doubt it has anything to do with this code, but if you can show me otherwise, I'll take a look.
Title: Cant catch problem properly   
Name: Mel
Date: 2005-06-13 6:19:26 PM
This code is good but when there is an error on the ASP server side code after flushing out the processing image to the browser, the error is not catch by the server side error handling routine you have.
Title: THnx   
Name: Roy Heaney
Date: 2005-06-02 5:36:28 AM
thnx just what i needed 4 my datadex.
Title: Useful function   
Name: Ann
Date: 2005-05-10 5:33:47 AM
very nice and functional.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-06-14 2:35:39 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search