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

Wait while Loading

Status
Not open for further replies.
Joined
Feb 4, 2002
Messages
792
Location
GB
Can anyone post some code snippets to help me set up a "Wait while loading..." message as an IFRAME loads a jasp page on my site?

Thanks,

Will
 
In parent page:

Code:
<script>
var iframeLoaded = false;
var mDiv;
window.onload='mDiv=document.getElementById("messageDiv");mDiv.innerHTML="Wait while loading";waitForIt();'
function waitForIt()
{
 
 if(!iframeLoaded)
 {
  if(mDiv.innerHTML.indexOf(".....") > -1)
   mDiv.innerHTML = "Wait while loading.";
  else
   mDiv.innerHTML += ".";

  setTimeout("waitForIt()", 1000);
 }
 else
  mDiv.innerHTML = "Loaded!";
}
<script>

In your IFRAME JSP, include:

Code:
<body onload='parent.iframeLoaded=true;'>

This sets the message into a DIV on the parent page. Every second the message gets another little dot on the end, unless there's five, in which case it goes back to one. This continues until the JSP in the IFRAME sends the message back that it's loaded.

Feel free to ask if any of this isn't clear. I could have commented the code better. I hope it makes sense.

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Thanks Dave. Problem is I still have the same problem. The messageDiv also does not show up until the jsp page finishes loading... This driving me crazy! :)

Here is the inner div control with the iframe. essentially it's the content part of an exactly sized square that is scrollable when content exceeds it's limit.

Code:
<div id="divContent">
   <table width="485">
      <tr>
         <td class="edit_blue">
            <b>London Stock Exchange Ordinary Stock </b><br><br>
         </td>
      </tr>
      <tr>
         <td class="edit_normal">
            <IFRAME src="[URL unfurl="true"]http://ww7.investorrelations.co.uk/pantheon/shareprice.jsp"[/URL] width="484" height="1000" scrolling="no" frameborder="0">
               [Your user agent does not support frames or is currently configured not to display frames. However, you may visit <A href="[URL unfurl="true"]http://ww7.investorrelations.co.uk/pantheon/shareprice.jsp">[/URL] the related document.</A>]
            </IFRAME>
         </td>
      </tr>
      <tr>
         <td class="edit_normal">
            Further details of PIP's portfolio can be found in the latest <a href="news.htm" class="black_link"> Report & Accounts</a>.<br><br>
         </td>
      </tr>
   </table>
</div>

When I add your code (I don't have full control over the above jsp, hence the iframe - so I just copied the source and used that instead, updating the onload event of the body tag) nothing changes.

Will
 
'been away for a few days...

How about removing the 'src' of the IFRAME and, instead, change the following (in the parent):

Code:
window.onload='mDiv=document.getElementById("messageDiv");mDiv.innerHTML="Wait while loading";waitForIt();';
to:
Code:
window.onload='[red]document.getElementById("myIframe").document.location="[URL unfurl="true"]http://ww7.investorrelations.co.uk/pantheon/shareprice.jsp";[/URL][/red]mDiv=document.getElementById("messageDiv");mDiv.innerHTML="Wait while loading";waitForIt();';
That way, the IFRAME won't even start loading until the parent page is drawn. Hmmm... Perhaps you should switch the statements around:
Code:
window.onload='mDiv=document.getElementById("messageDiv");mDiv.innerHTML="Wait while loading";waitForIt();document.getElementById("myIframe").document.location="[URL unfurl="true"]http://ww7.investorrelations.co.uk/pantheon/shareprice.jsp";';[/URL]
Note: this assumes that you have an ID parameter in your IFRAME tag, set equal to 'myIframe'.

Does that help?

Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...east is east and west is west and if you take cranberries and stew them like applesauce
they taste much more like prunes than rhubarb does
[infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top