Total members 11895 |It is currently Wed Dec 18, 2024 1:31 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Show code is used to show loading status message until the applet is fully loaded to the browser.

html code
<html>
<head>
<title>Your Title Here</title>
</head>

<script language="JavaScript">

<!-- Hide script from old browsers

function init()
{
// Microsoft Internet Explorer

if (document.all)
{
document.all.loading.style.visibility="hidden";
document.all.myapplet.style.visibility="visible";
document.applets[0].repaint();
}
// Netscape Navigator

else
{
document.loading.visibility="hide";
document.myapplet.visibility="visible";
}
}

// -->

</script>

<style type="text/css">

#loading {
position:absolute;
left:150;
top:200;
}

#myapplet {
position:absolute;
left:10;
top:10;
visibility:hide;
}

</style>

<body onLoad="init()">

<div id="loading">
<p>Loading applet, please wait.</p>
</div>

<div id="myapplet" style="visibility:hidden">
<applet archive="app1.jar" code="app1.class" align="baseline" width="620" height="442">
<p>Requires a browser that supports Java.</p>
</applet>
</div>

</body>
</html>

The Solution Explained

First, let's explain exactly what we're trying to do here. We want a message, such as "Loading applet, please wait." to be displayed while the applet is being loaded. This message should appear in the space that will be occupied by the applet, then be replaced by the applet once the applet has loaded.

The code shown above does a number of things to accomplish this.

Two <div> regions are created in the web page. The first contains the text (or image) to display while the applet is loading. The second contains the <applet> tag to load the applet. This second <div> has its visibility style set to hidden. This is required for IE.


html code
<div id="loading">
<p>Loading applet, please wait.</p>
</div>

<div id="myapplet" style="visibility:hidden">
<applet archive="app1.jar" code="app1.class" align="baseline" width="620" height="442">
<p>Requires a browser that supports Java.</p>
</applet>
</div>


Style sheets are defined for the two <div> tags. They both need positional styles. The style sheet for the <div> containing the <applet> tag also needs visibility set to hide (this is for Netscape). Positioning will have to be customized to the position of your applet, this is not a general solution.

css code
<style type="text/css">

#loading {
position:absolute;
left:150;
top:200;
}

#myapplet {
position:absolute;
left:10;
top:10;
visibility:hide;
}

</style>

A JavaScript function is defined which is run when the page loads :
javascript code
(<body onLoad="init()">).

Simply, this function hides the <div> containing the message and shows the <div> containing the applet.


javascript code
<script language="JavaScript">

function init()
{
if (document.all)
{
document.all.loading.style.visibility="hidden";
document.all.myapplet.style.visibility="visible";
document.applets[0].repaint();
}
else
{
document.loading.visibility="hide";
document.myapplet.visibility="visible";
}
}

</script>


This method should work equally well to place an image "over" the applet while it's loading.



_________________
Please recommend my post if you found it helpful. ,
java,j2ee,ccna ,ccnp certified .


Author:
Expert
User avatar Posts: 838
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : show loading status message until the applet is fully loaded
 Show loading image from JQuery     -  
 How to Show a message before the login ?     -  
 Loading table data from a CSV file     -  
 status Progress bar     -  
 Print all MySQL status value     -  
 Status Bar Link Description javascript code     -  
 Typing Status Bar Text javascript code     -  
 Solution to Error status zero when using Ajax with JQuery     -  
 JMS Message Consumer Example     -  
 Text message board RPG     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com