JavaScript中相应ActiveX事件
Html中ActiveX控件引用如下:
代码
<object id=axACCard1 style="LEFT: 0px; WIDTH: 164px; TOP: 0px; HEIGHT: 23px"
codeBase=http://localhost/AXICCard.cab#version=1,0,0,1
classid=clsid:C396CEBD-1D16-4CCD-B040-6BD79E318BF1>
</object>
codeBase=http://localhost/AXICCard.cab#version=1,0,0,1
classid=clsid:C396CEBD-1D16-4CCD-B040-6BD79E318BF1>
</object>
其中,axACCard1是控件的ID,GetCardCode是ActiveX事件,CardCode()是ActiveX的方法。
方法一:
<script language="javascript" for="axACCard1" event="GetCardCode">
alert(document.getElementById("axACCard1").CardCode());
</script>
alert(document.getElementById("axACCard1").CardCode());
</script>
方法二:
<script language="javascript" type="text/javascript">
function onGetCardevent()
{
alert(document.getElementById("axACCard1").CardCode());
}
document.getElementById("axACCard1").attachEvent("GetCardCode", onGetCardevent);
</script>
function onGetCardevent()
{
alert(document.getElementById("axACCard1").CardCode());
}
document.getElementById("axACCard1").attachEvent("GetCardCode", onGetCardevent);
</script>