Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Message.... 2

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Hello all --

It has been asked several times about displaying a user a message while your page loads if it takes a long time. I came up with this very simple little script this morning, and so I figured I'd share:

First, just make a page. Call it load.htm or something like that, and simply put the message in bold type or whatever: "Loading..."

Nothing fancy. Center it or whatever.

Then, on your ASP page, make sure that buffering is on like so:

response.buffer=true

and then put this bit of code right after your opening <body> tag:

<script language=javascript>
var url = 'load.htm';
var x = window.open(url,'loadingWindow','height=50,width=150,scrollbars=no,toolbar=no');
x.moveTo(200, 200);
</script>

Feel free to modify the parameters to suit your needs, but all this will do is popup a window with your message in it.

To make this work properly, you will need to do your processing AFTER this bit of client side code has been output. The simplest way to do this would be to incorporate everything into one main function for your ASP, and then call that right after you put the code above.

So for example:

<%
writeMainContent
%>

might be your next line, and that would be defined as a function on your ASP page, and it would do all your work.

The only thing left to do is to make another client side function. You might want to call it: 'closeLoader()' and it might look like this:

function closeLoader(){
x.close();
}


and then modify your body tag to look like this:

<body onLoad=&quot;closeLoader();&quot;>

and there you have it... once the page finishes rendering to your users' browsers, the little load.htm page will close out.

Very simple yet effective method to show your users that something is going on, and for them to just be patient.

:)
Paul Prewett

ps. Isn't it funny how many calculations people want incorporated into complex ASP pages, and how impatient they are when it comes to load times. ;-)

happy coding everyone!
penny.gif
penny.gif
 
Very nice.. Thank you !! :)

TW
 
Make your loading page look like this for something resembling a progress indicator:

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE>Loading...</TITLE>
<script language=javascript>
function dotIt(){
var i
for (i=0;i<=15;i++)
setTimeout('dotItAgain();',i*1000);
}
function dotItAgain(){
var value = theSpan.innerHTML;
theSpan.innerHTML = value + '.';
}
</script>
</HEAD>
<BODY onBlur=&quot;this.focus();&quot; onLoad=&quot;dotIt();&quot;>

<P align=left><STRONG><FONT face=Arial
size=4><span id=theSpan name=theSpan>Loading.</span></FONT></STRONG></P>

</BODY>
</HTML>

It'll keep putting periods after your &quot;loading&quot; message -- one every second for as long as you set your for loop to run (in seconds)

enjoy
:)
penny.gif
penny.gif
 
I use till now another method, who is kind of complicated but shows you the real time progress bar but u need the _ScriptLibrary from Microsoft and is based on Remote Object Scripting and works even in NS.
Anyway this is an simple solution...and works... ________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top