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="closeLoader();">
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!
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="closeLoader();">
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!