473,770 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1580

"Thomas Magma" <kh*****@beer.c om> schreef in bericht
news:U8NEb.7539 82$6C4.689918@p d7tw1no...
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.getEle mentById('apple tID');
try {
// Try calling one of the applet's methods
applet.some_met hod();
} catch (e) {
applet.style.di splay = 'none';
}
}
JW

Jul 20 '05 #2


Janwillem Borleffs wrote:
"Thomas Magma" <kh*****@beer.c om> schreef in bericht
news:U8NEb.7539 82$6C4.689918@p d7tw1no...
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.getEle mentById('apple tID');
try {
// Try calling one of the applet's methods
applet.some_met hod();
} catch (e) {
applet.style.di splay = '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 hideAppletsNotR unning () {
for (var i = 0; i < document.applet s.length; i++) {
var applet = document.applet s[i];
if (typeof applet.isActive == 'undefined') {
if (applet.style) {
applet.style.di splay = 'none';
}
}
}
}

window.onload = hideAppletsNotR unning;
</script>
</head>
<body>
<div>
<p>
Is the applet visible?
<applet name="appletNam e" 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
10899
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 somehow adding filename and date created in an array, sorting by date and then printing onto an html page with a link to that file. How would I do this though? Is this the simplest method or is there a better way of doin this?
5
12592
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 file may have been created but a crash occurred at that point in time (while it was being created), damaging the file. Now, my program which needs to read from this file, should first check that it's in good condition, and that it hasn't been...
5
3712
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 there is almost no Win32 code in it (only a few lines to do the idle priority class). What is the simplest way of programatically detecting the shutdown so I can dump my data to file? I would rather not put masses of Win32 code in there, is there...
2
3040
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 they successfuly download. My problem revolves around detecting a successful download, the steps I take to handle the download are as follows:
2
1802
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 programs state "file has changed on disk, reload?". I was wondering what strategy I should use in order to check temp files I have created to see if they have been changed by another process. My initial thought is to periodically check the files,...
1
2211
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
1502
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 several files that rarely change or are a list of the files in a directory that I rarely add or remove files from. Therefore, I want to be able to detect when a file is added to, removed from, or modified in one of these directories. Because I create...
1
1488
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 otherwise. Unfortunately I don't know how to properly detect VI. I've seen a trick for detecting VI, that goes something like: template <class B, class D> struct IsVirtualBaseAndDerived
5
8781
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 work. I am sure that this probably fairly simple, but I have not been able to figure it out. Z.K.
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.