5

I've got simple html on Login.aspx with an ActiveX object:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title></title>
<script language="javaScript" type="text/javascript"> 

    function getUserInfo() 
    {
        var userInfo = MyActiveX.GetInfo();
        form1.info.value = userInfo;
        form1.submit();
    }

</script>
</head>

<body onload="javascript:getUserInfo()">
<object id="MyActiveX" name="MyActiveX" codebase="MyActiveX.cab" classid="CLSID:C63E6630-047E-4C31-H457-425C8412JAI25"></object>
    <form name="form1" method="post" action="Login.aspx">
        <input type="hidden" id="info" name="info" value="" />
    </form>
</body>
</html>

The code works perfectly fine on my machine (edit: hosted and run), it does't work on the other: there is an error "Object doesn't support this property or method" in the first line of javascript function. The cab file is in the same folder as the page file. I don't know javascript at all and have no idea why is the problem occuring. Googling didn't help. Do you ave any idea?

Edit: on both machines IE was used and activex was enabled.

Edit2: I also added if (document.MyActiveX) at the beggining of the function and I still get error in the same line of code - I mean it looks like document.MyActiveX is true but calling the method still fails

3
  • Are you sure ActiveX is enabled on the machine you're failing on? Note that Zone will matter (local, intranet, internet) and have different security characteristics. Local, intranet zones typically have ActiveX off altogether by default. Commented Sep 22, 2009 at 7:42
  • checked it all - all zones have everything with activex enabled Commented Sep 22, 2009 at 7:46
  • same problem here. same page works in IE7 but not in IE8. Commented Jun 16, 2010 at 10:55

5 Answers 5

2

I think the onload event is making the function to run even before the ActiveX object is loaded. You may try the following instead:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title></title>
        <script language="javaScript" type="text/javascript">
            function getUserInfo(){
                if(document.MyActiveX){
                    var userInfo = MyActiveX.GetInfo();
                    form1.info.value = userInfo;
                    form1.submit();
                }
            }
        </script>
    </head>
    <body>
        <object id="MyActiveX" name="MyActiveX" codebase="MyActiveX.cab" classid="CLSID:C63E6630-047E-4C31-H457-425C8412JAI25"></object>
        <script for="window" event="onload" language="JavaScript">
            window.setTimeout("getUserInfo()", 500);
        </script>

        <form name="form1" method="post" action="Login.aspx">
            <input type="hidden" id="info" name="info" value="" />
        </form>
    </body>
</html>

Now the getUserInfo() function will start to run 500 milliseconds after the page is loaded. This must give some time for the ActiveX object to be loaded.

Sign up to request clarification or add additional context in comments.

6 Comments

Most of the times, ActiveX installation is blocked by the browsers. If using IE, a yellow alert bar appears asking whether you want to install the object. Only after the user's consent, the object will be installed. If the object is not loaded, then the function dealing with the object must check whether the required object is loaded. And hey, not all ActiveX objects are pre-loaded in everyone's machine.
Since you are calling the function as soon as the document loads, there is a possibility that the function runs even before the ActiveX object is loaded. Refer to my edited answer.
<object> supports the load event; OP could also try running getUserInfo() from there.
doesn't fire the js function at all
Are you sure the function is not fired? Can you recheck with an alert message inside the function?
|
2

IE8 manages access to the ActiveX on domain level.

To fix it:

  1. IE8, Tools -> Manage Add-ons
  2. In "Toolbars and Extensions" find your ActiveX
  3. Right click - More information
  4. Click - Allow on all sites
  5. Enjoy

Comments

0

maybe the browser on the other machine does not support activeX? just a wild guess

Comments

0

Maybe the ActiveX needs some prerequisite (For example CRuntime) that isn't present on the other machines? Have you tried running depends for the Activex on the hosting machine?

Comments

0

Maybe the other machine has a virus scanner or similar which silently prevents ActiveX use?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.