473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Could someone explain part of this function?

Hi
I have managed to Plagiarize and modify a piece of script that checks
to see if JAVA is installed on the users pc:

function javaInstalled()
{
result = false;
if (navigator.mime Types &&
navigator.mimeT ypes["applicatio n/x-java-vm"])
{
result = navigator.mimeT ypes["applicatio n/x-java-vm"].enabledPlugin;
}
else if (document.all && (navigator.appV ersion.indexOf( "Mac")==-1))
{
// IE Windows only -- check for ActiveX control, have to hide code
in eval from Netscape (doesn't like try)
eval ('try {var xObj = new ActiveXObject(" Javaplugin");if
(xObj) result = true; xObj = null; } catch (e) {}');
}
return result;
}

if (javaInstalled( ))
{
//do nothing
}
else
{
newWindow = window.open('../nojava.html', 'newWin',
'width=420,heig ht=250')
}

I have tried it on a machine that doesn't have JAVA installed and it
works exactly as i want it to. I can't however figure out what the
"eval ('try {var xObj = new ActiveXObject(" Javaplugin");if
(xObj) result = true; xObj = null; } catch (e) {}');"
bit means and it's importance, i know it doesn't work if its not
present!!!
Any help would be appreciated and also if it would work with Netscape(
not sure what the comment is saying)

Thanks

Nick

Jan 31 '06 #1
2 1673
Well technically you could just use:

window.navigato r.javaEnabled() ;

but it has some issues with older Netscape browsers (
http://segal.org/macjavabugs/enabled/ )

In terms of your question: the new ActiveXObject is an IE specific
Object that allows you to access ActiveX. I donno how reliable this is
since it is ActiveX. It seems to me with more and more browser security
issues that ActiveX could be disabled or unaccessible to your scripts.

The other concern I have with your example is the fact that eval is
used. In this case it does not seem neccessary to have that statement
wrapped in eval. It seems like a slowdown. You function code be
simplified:

function javaInstalled() {
// if we can quickly determine java is enable return quickly
if( window.navigato r.javaEnabled() ) return true;
// if netscape style plugins check to see if java is enabled
if (navigator.mime Types &&
navigator.mimeT ypes["applicatio n/x-java-vm"]) return true;
// if IE and not the Mac version need to check ActiveXObject
else if (document.all && (navigator.appV ersion.indexOf( "Mac")==-1)){
try {
// create a Java ActiveX Object
var xObj = new ActiveXObject(" Javaplugin");
if (xObj) return true;
} catch (e) {}
}
// if we get here we haven't detected java
return false;
}

I added comments and added a condition on the top of the function. I
did this because the script overhead will be greatly reduced if you
don't have to create an ActiveX object at least logic suggest so ;-)

Jan 31 '06 #2
Hi Nathan
Thanks for the reply
window.navigato r.javaEnabled() ; doesn;t actually work because as far
as i can work out it detects if it's enabled bit doesnot check if its
installed... ( i tried it on a machine with no JAVA ( or Microsoft JVM)
). The modified code doesn't work either, as testd against the
original. Thanks for your input.

Feb 1 '06 #3

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

Similar topics

21
1629
by: Gactimus | last post by:
Can anyone explain what the lines with the '*' by them do? ----------- #ifndef _COUNTER_H #define _COUNTER_H #include <iostream> using namespace std; class Counter
3
1582
by: MarcJessome | last post by:
Hi, I was wondering if someone could help me through learning C++. I've tried learning before, but I find I would work better if I had someone that could help explain a few things to me. Im using Bruce Eckel's Thinking in C++, but I have used others before. I use msn, icq and aim if its possible for someone to help me on an instant messenger. Thanks, Marc
5
11025
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after setting stDataSource and stFileName to the desired values. Most of the time it works, but occasionally, typically as code changes are being made to the module, the following message appears:
5
2793
by: J Allen Horner | last post by:
I'm just starting to learn C, and the tutorial I'm reading uses this code as an example: ----------- #include <stdio.h> #define MAX 10 int a; int rand_seed=10;
2
1231
by: William Morgan | last post by:
Public Declare Sub ydec_set_callback Lib "yDecLib.dll" (ByVal CallbackFunc As Long) Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal lpvDest As String, ByVal lpvSource As String, ByVal cbCopy As Long) Private Function yDecEventHandler(ByVal MsgType As Long, ByVal Data As Long, ByVal Msg As Long, ByVal MsgSize As Long) As Long ' this function handles all events fired by the decoder library ' for most events,...
3
2033
by: Jan Nielsen | last post by:
Hi I am working with rowfilters in dataviews. I would like to filter for empty fields (= null value in the database) I found this sentence on msdn: **************** To return only those columns with null values, use the following expression: "Isnull(Col1,'Null Column') = 'Null Column'" *************************' So I tried like this: mainDataSource.RowFilter = "Gender = 'male' and " & "Isnull(floor,'Null
3
1397
by: Chris H | last post by:
I have been looking through this script and came across something that I dont quite understand how it functions or is used. Basically its brackets that are added on at the end of a form field value. EXAMPLE: <input name="eid" type="hidden" id="eid" value="<? echo $ses_id; ?>"> in other words what does the brackets pass to the function thats processing the form, basically how is the used.
2
4851
by: blueyonder | last post by:
The statament below does exactly what I want it to do but I don't understand why? In my mind the subquery produces a result set which is a subset of the handset table which the initial part of the query is then applied to. However, the 'select all from Sim where it doesn't exists' is the bit I don't get where what doesn't exist? how is the comparison made? I haven't specified a parameter etc.. Any help would be much appreciated.
21
55608
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
0
8375
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
8290
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
8815
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
8707
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
6161
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
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
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
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.