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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page Caching/Loading 1

Status
Not open for further replies.

StylnR6

Programmer
Oct 27, 2000
4
CA
I have noticed that on some websites they have a page display that says, "please wait while page loads" and then it shows the complete page when loaded loaded. This makes the images apear at once, and the user knows that the page is loading. I was wondering how you could program this in javascript so that when all of my scripts and graphics are done, it displays the rest of the page page??? I don't want to target another page, I want this all to be done on the same html page. I was thinking of maybe showing a div with the page loading and then hiding it and displaying the rest of the page when it has finished processing, do you have any ideas for a function?? or do you know of any pages with this so that i can check out how they do it????
 
I've tried this using NN4 and IE5 and it seems to work (although it will only be apparent on pages which are slow to load). The DLOAD layer appears initially, but is replaced with the DMAIN layer (containing your page) once everything has been loaded :-

Insert this in the <HEAD> section:-

<SCRIPT language=&quot;Javascript&quot;>
<!--
function swapDivs () {
if (document.layers) {
document.DLOAD.visibility = 'hide';
document.DMAIN.visibility = 'show';
}
if (document.all) {
document.all.DLOAD.style.visibility = 'hidden';
document.all.DMAIN.style.visibility = 'visible';
}
}
//-->
</SCRIPT>

Then add the onLoad event to the <BODY> tag:-

<BODY onLoad='swapDivs();'.............>

Then within the <BODY> section :-

<DIV id='DLOAD' style=&quot;position:absolute; left:10; top:110; width:100%; height:100; visibility:visible;&quot;>
<CENTER>
<h1>Please wait - Page Loading</h1>
</CENTER>
</DIV>

<DIV id='DMAIN' style=&quot;position:absolute; left:10; top:10; visibility:hidden;&quot;>


Your HTML here.................


</DIV>

</BODY>
</HTML>

Enjoy :)

 
Thanks fatbloke for the fine tip.

I'd suggest a slight improvement (tested on IE4+, doesn't seem to work on my NN4, somebody knows why ?) :

SCRIPT language=&quot;Javascript&quot;>
<!--
function swapDivs () {
if (document.layers) {
document.body.visibility = 'show';
document.DLOAD.visibility = 'hide';
} ;
if (document.all) {
document.body.style.visibility = 'visible';
document.all.DLOAD.style.visibility = 'hidden';
} ;
}
//-->
</SCRIPT>

(note the impoortance of the body line before the DLOAD line)

...and :

<body onLoad=&quot;swapDivs();&quot; style=&quot;visibility:hidden;&quot;>

instead of :

---quote start---
<DIV id='DMAIN' style=&quot;position:absolute; left:10; top:10; visibility:hidden;&quot;>


Your HTML here.................


</DIV>
---quote end---

This way, you don't have to define a DMAIN span (useful for me on FrontPage98 with top borders).
 

<body onLoad=&quot;swapDivs();&quot; style=&quot;visibility:hidden;&quot;>


i guess that's why it's not working in nn !!!! (i hope for you coz at least it's a quick fix ;])
 
Sure, what you point doesn't work (the body is always visible).

But I meant that somewhere in

---begin quote---
if (document.layers) {
document.body.visibility = 'show';
document.DLOAD.visibility = 'hide';
} ;
---end quote---

there's something wrong for NN, because the DLOAD DIV doesn't hide.
 
does it find document.DLOAD ?? (try to alert document.DLOAD : if you get undefined sure you won't be able to hide it ;])
 
Actually NN says &quot;document.body has no properties&quot; (I guess this error makes it stop browsing the script, so the next line is not executed).

Well, it's not *my* opinion ! ;o)
 
yes, in devedge it appears that &quot;window&quot; is the object created with the <BODY> tag
therefore i guess the syntax to refer to the &quot;document.body&quot; is actually &quot;window&quot;
and yes, as soon as there is an error in the script, whatever the browser, it stops !
 

a.the window object is not the same as document.body
b.any layer you want to access in &quot;the other browser&quot; (until 6.0), you must access through the layers collection
(e.g. document.layers[&quot;DLOAD&quot;]) jared@aauser.com
 
how about the body then ? you have to create an artificial &quot;body layer&quot; or setting an absolute position for the body (??!!!) is enough ??
 
don't think you can hide it in NS - not positive though jared@aauser.com
 
:-( it's sad you can't play with &quot;the other browser&quot; until it's version 6 or more :-(
 
I doubt NS4 treats the window, the document, or the body like a layer as IE does. So, I would create an artificial body layer if that is what you wanted to do.

But, why not just define it like this:

<BODY onLoad='swapDivs()'>

<DIV id='DLOAD' style=&quot;position:absolute; left:0; top:0; width:100%; height:100%; visibility:visible; z-index:1000;&quot;>
<table width=&quot;100%&quot; height=&quot;100%&quot; align=&quot;center&quot; valign=&quot;center&quot;><tr><td align=&quot;center&quot; valign=&quot;center&quot;>
<h1>Please wait - Page Loading</h1>
</td></tr></table>
</DIV>

<SCRIPT language=&quot;Javascript&quot;>
<!--
function swapDivs () {
if (document.layers) {
document.layers.DLOAD.zIndex = 0;
(or visibility='hide')
}
if (document.all) {
document.all.DLOAD.style.zIndex = 0;
(or visibility='hidden')
}
}
//-->
</SCRIPT>

The point is -- why bother with two layers. Just put your loading layer on top of the rest of the page.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
This does work (thanks all !) :

<script language=&quot;Javascript&quot;>
<!--
function swapDivs () {
if (document.layers) {
window.visibility = 'show';
document.layers[&quot;DLOAD&quot;].visibility = 'hide';
} ;
if (document.all) {
document.body.style.visibility = 'visible';
document.all.DLOAD.style.visibility = 'hidden';
} ;
}
//-->

At least, when I say it works, I mean that :
a. it produces no error, even in NN, so the DLOAD layer does get hidden ;
b. but the body is *always* visible in NN4, for it doesn't implement the hidden in <body onLoad=&quot;swapDivs();&quot; style=&quot;visibility:hidden;&quot;>

Maybe <body onLoad=&quot;swapDivs();&quot; style=&quot;visibility:hide;&quot;> would do ? But how about IE then ?
 
Hi, got a problem where I must jump from an input page to an output page (jsps). Problem is that input has a hidden field and some cookie code, along with a Submit button. I cannot change this logic! Told that there is a way of automtically jumping from page to page.
Input page code is below:

<HTML>
<%@ content_type=&quot;text/html;charset=ISO-8859-1&quot; %>
<BODY>

<FORM METHOD=&quot;POST&quot; ACTION=&quot;<%= response.encodeUrl(&quot;Output.jsp&quot;) %>&quot;>

<%
//String id = request.getHeader(&quot;Cookie&quot;);
String Cookie_Name;
String Cookie_Value;
String id = &quot;&quot;;
Cookie[] cookies = request.getCookies();
if (null != cookies){
for (int i=0; i < cookies.length;i++){
Cookie_Name = cookies.getName();
Cookie_Value = cookies.getValue();
if (Cookie_Name.indexOf(&quot;userid&quot;) != -1){
id = Cookie_Value;
}
}
}
%>
<P><INPUT TYPE =&quot;hidden&quot; NAME=&quot;id&quot; SIZE=&quot;6&quot; VALUE=&quot;'<%=id %>'&quot;>
<P><INPUT TYPE=&quot;submit&quot; VALUE=&quot;Submit&quot;>

</FORM>
</BODY>
<% out.close(); %>
</HTML>

any ideas. Thanks
 
what is the problem ? this should jump to output.jsp without problem .... if someones actually clicks the submit button ...
 
hi iza....problem is client doesn't want this page to appear. its redundant on the front end but must be processed on the back end (its a host integration piece). back end app has a screen with 1 field on it (a dealer code) which, when keyed, leads to a detail screen. at the front end they've used the cookie code to obtain the dealer code (crazy init?). they've mapped the back end process and have to mirror it in order to run the front end! its one-step ahead of &quot;screen-scraping&quot;....
 
put the name of tha page you want to appear in the &quot;action&quot; part of the &quot;form&quot; tag
 
I have a situation where this solution wouldn't work since I have to wait for the file to be returned by the server performing a search. In my case it doesn't take a long time for the page to display rather a long time for the search to complete. Is there anyway to bump the user to a seperate page that says &quot;Loading&quot; and then when the server completes the search, bring the user to the search results. I think expedia.com does something like this. I just can't figure out how.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top