473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Detecting .class file

Hello,

I have a case where an applet .class file may or may not be present. In the
case when it is not present I get a big gray box where the applet is suppose
to be. This is understandable, but undesirable when someone is viewing or
printing the page. Is there a way to test first if the .class file is
present before hand in order to avoid the big gray box.

Thanks.
Jul 20 '05 #1
2 1561

"Thomas Magma" <kh*****@beer.com> schreef in bericht
news:U8NEb.753982$6C4.689918@pd7tw1no...
Hello,

I have a case where an applet .class file may or may not be present. In the case when it is not present I get a big gray box where the applet is suppose to be. This is understandable, but undesirable when someone is viewing or
printing the page. Is there a way to test first if the .class file is
present before hand in order to avoid the big gray box.


When the applet contains public methods which are accessible with
javascript, you could try the following:

window.onload = function () {
var applet = document.getElementById('appletID');
try {
// Try calling one of the applet's methods
applet.some_method();
} catch (e) {
applet.style.display = 'none';
}
}
JW

Jul 20 '05 #2


Janwillem Borleffs wrote:
"Thomas Magma" <kh*****@beer.com> schreef in bericht
news:U8NEb.753982$6C4.689918@pd7tw1no...
Hello,

I have a case where an applet .class file may or may not be present. In


the
case when it is not present I get a big gray box where the applet is


suppose
to be. This is understandable, but undesirable when someone is viewing or
printing the page. Is there a way to test first if the .class file is
present before hand in order to avoid the big gray box.

When the applet contains public methods which are accessible with
javascript, you could try the following:

window.onload = function () {
var applet = document.getElementById('appletID');
try {
// Try calling one of the applet's methods
applet.some_method();
} catch (e) {
applet.style.display = 'none';
}
}

That seems to be a good idea, only that you don't need some_method and
the try/catch, any applet extends the Applet class and thus should have
the public method isActive which you could check for with typeof.
I have tried the following with Netscape 7.1, IE6, and Opera 7 and the
applet (whose class file doesn't exist) is indeed hidden:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>applet test</title>
<script type="text/javascript">
function hideAppletsNotRunning () {
for (var i = 0; i < document.applets.length; i++) {
var applet = document.applets[i];
if (typeof applet.isActive == 'undefined') {
if (applet.style) {
applet.style.display = 'none';
}
}
}
}

window.onload = hideAppletsNotRunning;
</script>
</head>
<body>
<div>
<p>
Is the applet visible?
<applet name="appletName" code="anApplet.class" width="200" height="200">
</applet>
</p>
</div>
</body>
</html>
The only problem I see with that approach is that some browsers might
well run applets while not supporting LiveConnect (scripting access from
JavaScript to the applet's members) and then the above example would
hide a running applet as it exposes no methods.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: bissatch | last post by:
Hi, I am about to write an application that will display all pdf files in a folder and display them by file name in order of date. Is there an easy way of doing this? I was thinking about...
5
by: Jole | last post by:
Hi I'm writing a program that needs to read from a file. In order for the program to be robust, it should somehow check that the file isn't corrupt, or stuffed in any way. For example, that...
5
by: Rich | last post by:
I have a simple, single threaded program in C++ that runs as Idle priority. The program creates some data which needs dumping to file if the computer is shutdown or logged out. At the moment...
2
by: Sam-Kiwi | last post by:
I've spent the last 6 months developing a pay-per-download website using ASP.NET Users purchase documents and then download them. The intention is that users are only charged for documents...
2
by: Robin Tucker | last post by:
In the absence of IAdviceSink support in .NET (well, not the pure vanilla COM version anyway), I need to be able to tell when another process has saved changes to a file, in a similar way some...
1
by: Paul W | last post by:
I'm having trouble detecting whether my Control is in DesignMode. I'm deriving a class from TreeView; Public Class ExplorerView Inherits TreeView ... End Class
3
by: Nathan Sokalski | last post by:
I have several pieces of data that I use the HttpApplicationState for, because they rarely change and are used by everyone. When these pieces of data are created, they are created either from...
1
by: Imre | last post by:
Hi I'd like to create a special cast template function that can be used to cast a base pointer to a derived one, and uses dynamic_cast if virtual inheritance is involved, and static_cast...
5
by: Z.K. | last post by:
In C#, using the StreamReader, how do I detect when you get to the end of line. I am reading a text file using the Read() function and I need to detect the \n\r, but everything I try does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.