- Name of the
Esker ActiveX Plug-in file:
NPESKP32.DLL
- Installing
the Esker ActiveX Plug-in:
Just copy the file
NPESKP32.DLL to the PLUGINS subdirectory of the Netscape installation
directory (the directory containing the NETSCAPE.EXE
file).
Alternatively, you can use Netscape SmartUpdate technology
to install the Esker ActiveX Plug-in. For this, you will need to place
the NPESKP32.JAR file (containing the NPESKP32.DLL file) on the HTTP
server as well as some JavaScript code. In the source of this document,
there is an example of JavaScript code you can use (see functions
installPlugin and reloadPlugins).
- Declaring
an Active-X component in a HTML page for
Netscape:
<embed
type="application/x-eskerplus"
id="NfsdlgX"
classid="clsid:B9E1BC88-F93B-11D0-B473-00A02469E3BE"
codebase="nfsdlgX.ocx#version=2,0,0,0"
width="100%" height="100%"
param1="value1"
param2="value2"
onEvent1()="handler1()"
onEvent2(arg1,arg2,arg3)="handler2(arg1,arg2,arg3)">
This
corresponds exactly to the following OBJECT tag for Microsoft Internet
Explorer:
<object id="NfsdlgX"
classid="clsid:B9E1BC88-F93B-11D0-B473-00A02469E3BE"
codebase="nfsdlgX.ocx#version=2,0,0,0"
width="100%" height="100%"> <param
name="param1" value="value1"> <param
name="param2" value="value2"> </object>
<script
language=javascript for="NfsdlgX"
event="onEvent1()">
handler1() </script>
<script language=javascript
for="NfsdlgX" event="onEvent2(arg1,arg2,arg3)">
handler2(arg1,arg2,arg3) </script>
- Making
compatible HTML pages for Netscape and Microsoft Internet
Explorer:
<script
language=javascript> var NfsdlgActiveX = new
top.ActiveX; NfsdlgActiveX.id =
"NfsdlgX" NfsdlgActiveX.classid =
"clsid:B9E1BC88-F93B-11D0-B473-00A02469E3BE"
NfsdlgActiveX.codebase =
"nfsdlgX.ocx#version=2,0,0,0" NfsdlgActiveX.width
= "100%" NfsdlgActiveX.height =
"100%" NfsdlgActiveX.defineParm ("param1",
"value1"); NfsdlgActiveX.defineParm ("param2",
"value2"); NfsdlgActiveX.defineParm ("param2",
"value2"); NfsdlgActiveX.handleEvent
("onEvent1()", "handler1()");
NfsdlgActiveX.handleEvent ("onEvent2(arg1,arg2,arg3)",
"handler2(arg1,arg2,arg3)"); document.write
(NfsdlgActiveX.instanciate());
NfsdlgActiveX=null </script>
This declaration uses a
JavaScript object called "ActiveX" defined like
this:
<script language=javascript> function ActiveX
() { this.netscape = (window.navigator.appName
== "Netscape"); this.installation = this.netscape
&& !navigator.plugins ["Esker ActiveX
Plug-in"]; this.width = 100;
this.heigh = 100; this.parameters = new Array
(0); this.events = new Array
(0); this.defineParam =
ActiveX_defineParam; this.handleEvent =
ActiveX_handleEvent; this.instanciate =
ActiveX_instanciate; } function ActiveX_defineParam (name,
value) { if
(this.netscape)
{ this.parameters
[this.parameters.length] = '\n' + name + '="' + value +
'"'; }
else
{ this.parameters
[this.parameters.length] = '\n<param name="' + name + '" value="' +
value + '">'; } } function
ActiveX_handleEvent (name, value) { if
(this.netscape)
{ this.events
[this.events.length] = '\n' + name + '="' + value +
'"'; } else if
(this.id)
{ this.events
[this.events.length] = '\n<scr' + 'ipt language=javascript for="' +
this.id + '" event="' + name + '">\n' + value + '\n<' + '/sc' +
'ript>'; } } function ActiveX_instanciate
() { var tag = ""; if
(!this.installation)
{ if
(this.netscape)
{
tag += '<embed
type="application/x-eskerplus"';
}
else
{
tag += '<object';
} if (this
["id"])
{
tag += '\nid="' + this.id +
'"';
} else if (this
["name"])
{
tag += '\nid="' + this.name +
'"';
} if (this
["classid"])
{
tag += '\nclassid="' + this.classid +
'"';
} if (this
["codebase"])
{
if
(this.netscape)
{
if (this
["deployer"])
{
this.codebase =
this.deployer;
}
else
{
var extension = this.codebase.indexOf
(".cab");
if (extension >=
0)
{
this.codebase = this.codebase.substring (0, extension) + ".ocx" +
this.codebase.substring (extension + 4,
this.codebase.length);
}
}
}
tag += '\ncodebase="' + this.codebase +
'"';
} if (this.width == null
|| this.width == 0 || this.width ==
"0")
{
this.width = 2;
} tag += '\nwidth="' +
this.width + '"'; if
(this.height == null || this.height == 0 || this.height ==
"0")
{
this.height = 2;
} tag += '\nheight="' +
this.height + '"'; if
(!this.netscape)
{
tag += '>';
} for (var index = 0;
index < this.parameters.length;
index++)
{
tag += this.parameters
[index];
} if
(this.netscape)
{
for (var index = 0; index < this.events.length;
index++)
{
tag += this.events
[index];
}
tag += '>';
}
else
{
tag +=
'\n</object>';
for (var index = 0; index < this.events.length;
index++)
{
tag += this.events
[index];
} }
} return
tag; } </script>
- General
Differences between IE & NetScape:
Beside the usual
differences between IE and Netscape (case sensitivity...) there are some
specific differences for ActiveX controls:
5a) The "onLoad"
event of the HTML body object is fired by Netscape before the ActiveX
controls are actually activated. A good way to use the "onLoad" event is
as follow:
<body language=javascript
onLoad="Init()"> <script
language=javascript> function Init
() {
if (window ["NfsdlgX"])
{
// the activex control is
activated
NfsdlgX.DoYourThings ();
}
else
{
// the activex control is not activated yet, retry
later...
setTimeout ("Init()",
100);
} } </script>
5b) The
"onUnload" event of the HTML body object is fired by Netscape after the
plug-ins are unloaded. That means that the "onUnload" event handler
cannot call ActiveX control methods.
5c) Javascript
callback limitation: an ActiveX control may be passed a javascript
object and may call methods of this javascript object. The javascript
callback code must not in turn call directly ActiveX methods nor the
javascript "window.alert" method. Instead this call must be done
asynchronously using "setTimout":
if
(error)
{ setTimeout ('alert ("an
error has occured!")', 0);
} else
{ setTimeout
('NfsdlgX.DoIt()', 0); }
The same
limitation applies in javascript event handlers. Note:
"setTimeout" inside a "setTimeout" does not always work in
Netscape.
5d) Because Esker ActiveX Plug-in uses Netscape
LiveConnect technology, arguments passed to javascript callbacks are in
fact java objects. As java objects are compared by reference and not by
values, it is sometimes necessary to change these arguments to actual
javascript objects using the following
technique:
var string1 = "" + arg1; // a
string argument var boolean2 = ("true" == "" +
arg2); // a boolean argument var number3 = 0 +
arg3; // a numeric argument
5e) The Esker ActiveX lug-in needs
the ActiveX type info. ActiveX controls developed with Microsoft MFC
expose a ITypeInfo interface automatically but some sub-objects (derived
from the CCmdTarget class) may not expose theirs. To call methods on
these sub-objects from javascript, it is required that the ITypeInfo
interface be exposed explicitly. To do this, the following code must be
added to the ActiveX class declaration:
DECLARE_OLETYPELIB (CSubObject) virtual BOOL
GetDispatchIID (IID* pIID);
And to the ActiveX class
definition:
IMPLEMENT_OLETYPELIB (CSubObject,
_tlid, _wVerMajor, _wVerMinor)
CSubObject::CSubObject()
{ AfxOleLockApp
();
EnableAutomation();
EnableTypeLib (); }
CSubObject::~CSubObject()
{ AfxOleUnlockApp
(); }
BOOL
CCrypt::GetDispatchIID (IID* pIID)
{ *pIID =
IID_ISubObject; return
TRUE; }
5f) ActiveX controls loaded in
Netscape by Esker ActiveX Plug-in must be declared safe for scripting
(and safe for initializing if they expose the IPropertyBag interface).
There are no settings to ask a confirmation to the user to override this
behaviour.
5g) Security issue. The Esker ActiveX Plug-in
is basically designed for intranet/extranet application only, not for
internet. ActiveX placed on a server outside the intranet are not
downloaded because they are not considered as trusted. There is no
confirmation asked to the user. Extranet applications are addressed by
declaring the HTTP server as part of the domain of the extranet user in
is DNS. Alternatively, each individual extranet user may add the name of
the the HTTP server in the DEPLOYER.INI file under the Windows
directory:
[TrustedServers] www.ourcompany.com=yes
Note: using HTTPS allows the download of any ActiveX from any
server owning a valid certificate.
5h) The Esker ActiveX
Plug-in does not implement the CAB format. To download complex ActiveX
components that depend on other components you must either declare these
components in the HTML page or use a DPL file. The DPL format is the
format used in the Esker PLUS product line.
|