最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ActiveX on Windows 7 throws "Object doesn't support property or method" error - Stack Ove

programmeradmin2浏览0评论

We have a third-party ActiveX. It seems to be working fine on a Windows XP machine (Internet Explorer 7). However, when we test on Windows 7 Professional 64-bit (Internet Explorer 9), we receive an error message -- "Object doesn't support property or method '{methodname}'"

Anyone knows what could be causing this?

  • Is there a problem with the OS -- security is tighter, therefore the assembly needs something?

  • Is there a problem with the browser -- again, maybe security is tighter, therefore something in Tools >> Internet Options >> Security needs to be adjusted?

Thoughts or suggestions would be greatly appreciated!

HTML:

<body onload="OpenActiveX()">
    <OBJECT id="OurActiveX" 
        name=”OurActiveX" 
        classid="clsid:43663B77-905C-4885-BC6B-4F57FE10A270" 
        VIEWASTEXT codebase="CS1504CAB.cab">
    </OBJECT>

    <script language="javascript">
        function OpenActiveX()
        {
            try
            {
                alert(document.OurActiveX.Echo("Hi I am here."));
                var sdata = document.OurActiveX.GetData();
                if(sdata == "0"){
                    document.getElementById("barcodes").innerHTML = "No barcodes found.";
                }
                else if( sdata == "1"){
                    document.getElementById("barcodes").innerHTML = "Could not find the barcode reader.";
                }
                else{
                    var adata = sdata.split(":");
                    document.getElementById("barcodes").innerHTML = adata[0] + "<BR/>" + adata[1];
                }
            }
            catch(Err)
            { 
                alert(Err.description);
            }
        }
    </script> 
<div id="barcodes" />

We have a third-party ActiveX. It seems to be working fine on a Windows XP machine (Internet Explorer 7). However, when we test on Windows 7 Professional 64-bit (Internet Explorer 9), we receive an error message -- "Object doesn't support property or method '{methodname}'"

Anyone knows what could be causing this?

  • Is there a problem with the OS -- security is tighter, therefore the assembly needs something?

  • Is there a problem with the browser -- again, maybe security is tighter, therefore something in Tools >> Internet Options >> Security needs to be adjusted?

Thoughts or suggestions would be greatly appreciated!

HTML:

<body onload="OpenActiveX()">
    <OBJECT id="OurActiveX" 
        name=”OurActiveX" 
        classid="clsid:43663B77-905C-4885-BC6B-4F57FE10A270" 
        VIEWASTEXT codebase="CS1504CAB.cab">
    </OBJECT>

    <script language="javascript">
        function OpenActiveX()
        {
            try
            {
                alert(document.OurActiveX.Echo("Hi I am here."));
                var sdata = document.OurActiveX.GetData();
                if(sdata == "0"){
                    document.getElementById("barcodes").innerHTML = "No barcodes found.";
                }
                else if( sdata == "1"){
                    document.getElementById("barcodes").innerHTML = "Could not find the barcode reader.";
                }
                else{
                    var adata = sdata.split(":");
                    document.getElementById("barcodes").innerHTML = adata[0] + "<BR/>" + adata[1];
                }
            }
            catch(Err)
            { 
                alert(Err.description);
            }
        }
    </script> 
<div id="barcodes" />
Share Improve this question edited May 2, 2014 at 9:15 Melquiades 8,5981 gold badge35 silver badges48 bronze badges asked Nov 9, 2011 at 14:50 Glen J FergoGlen J Fergo 1341 gold badge1 silver badge10 bronze badges 2
  • Without seeing any of the code used, it's pretty hard to say. That error can be caused by a vast number of situations. – Pointy Commented Nov 9, 2011 at 15:11
  • You make an excellent point! I apologize. I have edited my question to include the HTML. Thank you for your guidance! – Glen J Fergo Commented Nov 9, 2011 at 15:27
Add a ment  | 

3 Answers 3

Reset to default 2

The error message indicates that the control is not available on the machine. You can check the security settings of IE on the client machine and verify the following security settings of IE to "Prompt" or "Enabled":

1) Download signed ActiveX controls 2) Run ActiveX Controls and plug-ins 3) Script ActiveX controls marked safe for scripting

Protected Mode is On by default in Windows 7. Turn the proected mode off or try running IE as administrator can get rid of the security problem.

Also, if you are using 64-bit IE, you need to make sure that the control supports 64-bit.

There is no document.OurActiveX, because the name attribute in your HTML is broken (you've used a "smart quotes" in place of a normal double quote — if you look carefully, the syntax highlighting gives this away).

So, in fact, document.OurActiveX is undefined, and that's why you can't invoke any methods on it.

<OBJECT id="OurActiveX" name=”OurActiveX" classid="..."></OBJECT>

Bees:

<OBJECT id="OurActiveX" name="OurActiveX" classid="..."></OBJECT>

Anyway, selecting DOM nodes like document.someName is highly antiquated and a little error-prone; get rid of the name attribute entirely and use document.getElementById to select the node, like you have elsewhere.

ActiveX doesn't work with 64bit IE.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论