简体   繁体   中英

Call ActiveX method from JavaScript in IE9

I have an activex control on the page. Usually, to call it methods I use something like this:

document.getElementById('activexControlID').MethodName(2) = 'value string';

I know, that it may looks strange, but it works fine in IE6, IE7, IE8. Unfortunately, it doesn't work in IE9. It throws the error "Cannot assign to a function result".

I already tried:

document.getElementById('activexControlID').MethodName[2] = 'value string';
// and
document.getElementById('activexControlID').MethodName(2, 'value string');

but with no luck.

UPDATE

The expression document.getElementById('activexControlID').MethodName(2) = 'value string'; do not suppose to return a value. It acts like a setter. After all, I can get it later with the code var value = document.getElementById('activexControlID').MethodName(2); And I can get the value in IE9. But can not set it.

I don't know how it is implemented inside the activex control, but it is similar to array, just uses () instead of [] . And once again, it works in previous versions of IE.

UPDATE 2

Looks like a bug in IE9. Hope will be fixed.

The bug was fixed and the code

document.getElementById('activexControlID').MethodName(2) = 'some value';

now works in the IE9 RC1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM