我的网站上有下一个代码。此代码是一个 c# activex,函数 alert(MyCC.GetID().Fullname) 有效但事件无效。我做错了什么?
<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>
最佳答案
在 Javascript 中接收这些事件的正确语法如下:
function MyCC::CardInserted () { }
或
MyCC::CardInserted = function () { }
当然,您不必指定匿名函数:
MyCC::CardInserted = OnCardInserted;
关于c# - ActiveX 事件在 javascript 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1153078/