views:

90

answers:

2

I have next code in my website. This code is an c# activex, the function alert(MyCC.GetID().Fullname) works but events not work. What i doing wrong?

<object id="MyCC" codebase="http://localhost:3239/WebDAVCab.CAB" 
  classid="clsid:5F9A5DDB-0D35-4893-A9ED-1FAFFE94373A" width="80" height="120" VIEWASTEXT>
</object>

<script type="text/javascript">
        MyCC = document.getElementById("MyCC");
        alert(MyCC.GetID().Fullname);

        MyCC.CardInserted = OnCardInserted;
        MyCC.CardRemoved = OnCardRemoved;

        function OnCardInserted()
        {
            alert("raised");
        }
        function OnCardRemoved()
        {
            alert("raised2");
        } 
    </script>
A: 
  1. try using MyCC.attachEvent('CardInserted', OnCardInserted); instead
  2. You also need to implement IObjectSafety
Shay Erlichmen
I tried but not fire. Introduced this control in windows forms and work very well, all events is fired in windows forms but no in html/javascript.
pho3nix
A: 

The correct syntax for sinking these events in Javascript is as follows:

function MyCC::CardInserted () { }

or

MyCC::CardInserted = function () { }

Naturally, you don't have to specify an anonymous function:

MyCC::CardInserted = OnCardInserted;
Andy E
I tested but return a error in MyCC:: i get a ie error Expected ;
pho3nix