JScript event handler for ActiveX DLL events within IE 
Author Message
 JScript event handler for ActiveX DLL events within IE

Anyone have a URL or sample on assigning a JScript event
handler for a custom ActiveX DLL object created with VB6,
hosted within IE 5.5+ on the client?

I read that it should be function Object::Event() {} but I
get an "Object" not defined error only when this method is
present (same for Object.Event()) otherwise the object
works perfectly.  The object is instantiated using new
ActiveXObject().  

http://www.*-*-*.com/
us/dnclinic/html/scripting04092001.asp?frame=true

Thanks.



Sun, 31 Jul 2005 06:44:39 GMT  
 JScript event handler for ActiveX DLL events within IE
Hi
Try to insert the 'DEFER' in the script tag:
<script language="javascript" DEFER >

"Using the attribute at design time can improve the
download performance of a page because the browser does
not need to parse and execute the script and can continue
downloading and parsing the page instead."

Quote:
>-----Original Message-----
>Anyone have a URL or sample on assigning a JScript event
>handler for a custom ActiveX DLL object created with VB6,
>hosted within IE 5.5+ on the client?

>I read that it should be function Object::Event() {} but
I
>get an "Object" not defined error only when this method
is
>present (same for Object.Event()) otherwise the object
>works perfectly.  The object is instantiated using new
>ActiveXObject().  

>http://msdn.microsoft.com/library/en-
>us/dnclinic/html/scripting04092001.asp?frame=true

>Thanks.
>.



Sun, 31 Jul 2005 20:05:15 GMT  
 JScript event handler for ActiveX DLL events within IE


Quote:
> Anyone have a URL or sample on assigning a JScript event
> handler for a custom ActiveX DLL object created with VB6,
> hosted within IE 5.5+ on the client?

I used Microsoft's Calendar Control and attached to the "AfterUpdate" event.
Here is a sample:

<html>
<head>

<title>Test Calendar Control</title>
<script type="text/javascript">
var calendar;
function buttonClicked ( ) {
 calendar.object.AboutBox ( );

Quote:
}

function calendarUpdated ( ) {
 alert ( calendar.object.Value );

Quote:
}

function initialize ( ) {
 calendar = document.getElementById ( "CalendarControl" );
 calendar.attachEvent ( "AfterUpdate", calendarUpdated );
 calendar.object.BackColor = 0xFFFFFF;
Quote:
}

</script>

</head>
<body onload="initialize ( )">

<object id="CalendarControl"
classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02" ></object>

<input type="button" onclick="buttonClicked ( )" value="About">

</body>
</html>



Sun, 31 Jul 2005 20:44:08 GMT  
 JScript event handler for ActiveX DLL events within IE
Anyone have a solution along these lines with the object being a VB6 activeX
dll.  I want to avoid using an <object> do to external referencing issues.
Also using the defer attribute seems to have no impact.

   <script language="Jscript">
      var obj = new ActiveXObject("dll.object");

      function obj::CustomEvent(){
         alert("test");
      }
   </script>

This gives me an "obj" not defined error.

Shawn


Quote:



> > Anyone have a URL or sample on assigning a JScript event
> > handler for a custom ActiveX DLL object created with VB6,
> > hosted within IE 5.5+ on the client?

> I used Microsoft's Calendar Control and attached to the "AfterUpdate"
event.
> Here is a sample:

> <html>
> <head>

> <title>Test Calendar Control</title>
> <script type="text/javascript">
> var calendar;
> function buttonClicked ( ) {
>  calendar.object.AboutBox ( );
> }

> function calendarUpdated ( ) {
>  alert ( calendar.object.Value );
> }

> function initialize ( ) {
>  calendar = document.getElementById ( "CalendarControl" );
>  calendar.attachEvent ( "AfterUpdate", calendarUpdated );
>  calendar.object.BackColor = 0xFFFFFF;
> }
> </script>

> </head>
> <body onload="initialize ( )">

> <object id="CalendarControl"
> classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02" ></object>

> <input type="button" onclick="buttonClicked ( )" value="About">

> </body>
> </html>



Mon, 01 Aug 2005 00:34:03 GMT  
 JScript event handler for ActiveX DLL events within IE
Did you try:

   <script language="Jscript">
      var obj = new ActiveXObject("dll.object");
      obj.attachEvent ("CustomEvent", customevent_handler);

      function customevent_handler(){
         alert("test");
      }

   </script>

Also - posting with a name 'Microsoft' is a bit misleading perhaps? Unless of course you do work for MS?

Chris.

Anyone have a solution along these lines with the object being a VB6 activeX
dll.  I want to avoid using an <object> do to external referencing issues.
Also using the defer attribute seems to have no impact.

   <script language="Jscript">
      var obj = new ActiveXObject("dll.object");

      function obj::CustomEvent(){
         alert("test");
      }
   </script>

This gives me an "obj" not defined error.

Shawn


Quote:



> > Anyone have a URL or sample on assigning a JScript event
> > handler for a custom ActiveX DLL object created with VB6,
> > hosted within IE 5.5+ on the client?

> I used Microsoft's Calendar Control and attached to the "AfterUpdate"
event.
> Here is a sample:

> <html>
> <head>

> <title>Test Calendar Control</title>
> <script type="text/javascript">
> var calendar;
> function buttonClicked ( ) {
>  calendar.object.AboutBox ( );
> }

> function calendarUpdated ( ) {
>  alert ( calendar.object.Value );
> }

> function initialize ( ) {
>  calendar = document.getElementById ( "CalendarControl" );
>  calendar.attachEvent ( "AfterUpdate", calendarUpdated );
>  calendar.object.BackColor = 0xFFFFFF;
> }
> </script>

> </head>
> <body onload="initialize ( )">

> <object id="CalendarControl"
> classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02" ></object>

> <input type="button" onclick="buttonClicked ( )" value="About">

> </body>
> </html>



Mon, 01 Aug 2005 00:51:50 GMT  
 JScript event handler for ActiveX DLL events within IE
Quote:
>Did you try:

>   <script language="Jscript">
>      var obj = new ActiveXObject("dll.object");
>      obj.attachEvent ("CustomEvent",

customevent_handler);

Quote:

>      function customevent_handler(){
>         alert("test");
>      }

>   </script>

This doesn't work either.  "Object doesn't support this
property or method."

Quote:
>Also - posting with a name 'Microsoft' is a bit

misleading perhaps? Unless of course you do work for MS?

Interesting bug in using outlook express to post a
response.

Quote:

>Chris.

>I want to avoid using an <object> do to external
referencing issues.
>Also using the defer attribute seems to have no impact.

>   <script language="Jscript">
>      var obj = new ActiveXObject("dll.object");

>      function obj::CustomEvent(){
>         alert("test");
>      }
>   </script>

>This gives me an "obj" not defined error.

>Shawn




message

>> > Anyone have a URL or sample on assigning a JScript
event
>> > handler for a custom ActiveX DLL object created with
VB6,
>> > hosted within IE 5.5+ on the client?

>> I used Microsoft's Calendar Control and attached to
the "AfterUpdate"
>event.
>> Here is a sample:

>> <html>
>> <head>

>> <title>Test Calendar Control</title>
>> <script type="text/javascript">
>> var calendar;
>> function buttonClicked ( ) {
>>  calendar.object.AboutBox ( );
>> }

>> function calendarUpdated ( ) {
>>  alert ( calendar.object.Value );
>> }

>> function initialize ( ) {
>>  calendar = document.getElementById

( "CalendarControl" );

- Show quoted text -

Quote:
>>  calendar.attachEvent ( "AfterUpdate",
calendarUpdated );
>>  calendar.object.BackColor = 0xFFFFFF;
>> }
>> </script>

>> </head>
>> <body onload="initialize ( )">

>> <object id="CalendarControl"
>> classid="clsid:8E27C92B-1264-101C-8A2F-040224009C02"
></object>

>> <input type="button" onclick="buttonClicked ( )"
value="About">

>> </body>
>> </html>

>.



Mon, 01 Aug 2005 01:14:09 GMT  
 JScript event handler for ActiveX DLL events within IE


Quote:
> >Did you try:

> >   <script language="Jscript">
> >      var obj = new ActiveXObject("dll.object");
> >      obj.attachEvent ("CustomEvent",
> customevent_handler);

> >      function customevent_handler(){
> >         alert("test");
> >      }

> >   </script>

> This doesn't work either.  "Object doesn't support this
> property or method."

The attachEvent method is to attach a function to any of the standard DHTML
events (i.e. the object is wrapped in a DHTML element). So attachEvent not
working on the ActiveX object makes sense.

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/att...
t.asp

IE seems to wraps the object for you when you put it in <OBJECT>, exposing
all of the published events. You might try fiddling with dynamically
creating an <OBJECT> element and then inserting your ActiveXObject. Not sure
if or how, but just an idea.



Mon, 01 Aug 2005 02:20:31 GMT  
 JScript event handler for ActiveX DLL events within IE
Ok - was just an idea.

I'm unfamiliar with responding to events from COM into script - I had believed that it was not possible given the
constraints of not being strongly typed?

Chris.


Quote:
> >Did you try:

> >   <script language="Jscript">
> >      var obj = new ActiveXObject("dll.object");
> >      obj.attachEvent ("CustomEvent",
> customevent_handler);

> >      function customevent_handler(){
> >         alert("test");
> >      }

> >   </script>

> This doesn't work either.  "Object doesn't support this
> property or method."

The attachEvent method is to attach a function to any of the standard DHTML
events (i.e. the object is wrapped in a DHTML element). So attachEvent not
working on the ActiveX object makes sense.

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/att...
t.asp

IE seems to wraps the object for you when you put it in <OBJECT>, exposing
all of the published events. You might try fiddling with dynamically
creating an <OBJECT> element and then inserting your ActiveXObject. Not sure
if or how, but just an idea.



Mon, 01 Aug 2005 03:38:44 GMT  
 JScript event handler for ActiveX DLL events within IE

Quote:
> Ok - was just an idea.

I had the same one -- and wondered why it did not work too. The only bad
idea is the one not expressed.

Quote:
> I'm unfamiliar with responding to events from COM into script - I had

believed that it was not possible given the

Quote:
> constraints of not being strongly typed?

Interesting. I never really thought of JavaScript not being strongly typed
as a constraint, but I think you are right. Something has to deal with the
extra level of indirection because references to JavaScript functions are
not function pointers.

If you look at the COM objects that are typically scripted outside of the
browser (FileSystemObject, WSH, WScript) none of them expose events. Whereas
the few examples that I have seen of COM object used inside of the browser
are either wrapped in <OBJECT> (so they can respond to events), or are the
statement-driven types like FileSystemObject, ADO, or WSH.

Dale Hurtt



Mon, 01 Aug 2005 21:08:30 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Add an event handler to the actual event handler for an element

2. JScript Event handler for activex object

3. Determining which object fired event from event handler.

4. onchange event/event handler not triggering

5. ActiveX Event Handlers

6. Calling a JScript event handler

7. COM Event Handlers with JScript

8. Setting event handlers in JScript

9. Creating Event Handlers - How come always JScript?

10. JScript event handlers in WSH

11. Catching Events in an ActiveX-DLL

12. how to handle com events within a jscript but not a wscript environment

 

 
Powered by phpBB® Forum Software