How to handle an ActiveX event in Javascript

后端 未结 7 1367
半阙折子戏
半阙折子戏 2020-11-28 07:58

This is somewhat of a follow-up to an answer here.

I have a custom ActiveX control that is raising an event (\"ReceiveMessage\" with a \"msg\" parameter) that needs

7条回答
  •  离开以前
    2020-11-28 08:44

    I have used activex in my applications before. i place the object tags in the ASP.NET form and the following JavaScript works for me.

    function onEventHandler(arg1, arg2){
        // do something
    }
    
    window.onload = function(){
        var yourActiveXObject = document.getElementById('YourObjectTagID');
        if(typeof(yourActiveXObject) === 'undefined' || yourActiveXObject === null){
            alert('Unable to load ActiveX');
            return;
        }
    
        // attach events
        var status = yourActiveXObject.attachEvent('EventName', onEventHandler);
    }
    

提交回复
热议问题