Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 913
Andrey M. Avatar asked Jun 28 '26 03:06

Andrey M.


1 Answers

The bug was fixed and the code

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

now works in the IE9 RC1.

like image 51
Andrey M. Avatar answered Jun 30 '26 18:06

Andrey M.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!