IE为什么不响应ocx的事件?
我在IE中嵌入了一个VC写的控件,然后控件的所有方法和属性的访问都正常,但是就是用Javascipt写的代码里面不能响应该事件(就是IE没有反映,也不抱任和错误),控件的事件在ActiveX测试容器中是正常的。
谁碰到过类似的问题啊?
IE代码:
<html>
<head>
<script language="javascript">
<!--
function AgentStateChange(state,env,timestamp)
{
alert(state);
}
function InitializeOcx()
{
//var ocxAgent=new AgentOcx();
var nRet=ocxAgent.Initialize("tcp","192.168.1.200","11000");
alert(nRet);
ocxAgent.attachEvent("OnStateChange2",AgentStateChange);
}
function ReleaseOcx()
{
ocxAgent.Release();
}
function AgentLogin()
{
var nRet=ocxAgent.Login("liugang","","1899");
alert(nRet);
/*alert(ocxAgent.AgentName);
alert(ocxAgent.AgentGroup);
alert(ocxAgent.AgentType);*/
}
function AgentLogout()
{
var nRet=ocxAgent.Logout();
alert(nRet);
}
//-->
</script>
</head>
<body onload="InitializeOcx();" onunload="ReleaseOcx();">
<OBJECT id=ocxAgent classid=CLSID:C41ACE17-6DFB-4644-B84A-134B5499A72C name=ocxAgent VIEWASTEXT event="true">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="1905">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
</OBJECT>
<script type="text/javascript" for="ocxAgent" event="OnStateChange()" defer>
alert("State");
</script>
<a href="javascript:AgentLogin();">注册</a><p>
<a href="javascript:AgentLogout();">注销</a>
</body>
</html>