Test 1 uses the "for" tag to setup the callback to the activeX event. This is successful on all versions IE8, 9, 10 and 11.
<!DOCTYPE html>
<html>
<head>
<title>TestEvent Example HTML</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script language='javascript' for="testAxEvent" event="testEvent(szType, szValue)">
// Test 1 - statically load the script (This is the basis for the hack)
// Works on IE8, IE9, IE10 and IE11
var MSG = document.getElementById("msg");
MSG.innerHTML = szType + " : " + szValue;
</script>
</head>
<body>
<table>
<tr>
<td>
<OBJECT ID='testAxEvent' CLASSID='CLSID:BA19A985-C93E-491B-B801-2EB7F903C8CE' codebase="testAxEvent.cab"></OBJECT>
</td>
</tr>
<tr><td height='30'></td></tr>
<tr>
<td align=center><font size=5><div id='msg'></div></font>
</tr>
</table>
</body>
</html>
Test 2 uses attachEvent to bind the callback to the object element. The callback is correctly called on IE8, 9 and 10 but not on IE11, as was expected.
<!DOCTYPE html>
<html>
<head>
<title>TestEvent Example HTML</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<table>
<tr>
<td>
<OBJECT ID='testAxEvent' CLASSID='CLSID:BA19A985-C93E-491B-B801-2EB7F903C8CE' codebase="testAxEvent.cab" width='120' height='80'></OBJECT>
</td>
</tr>
<tr><td height='30'></td></tr>
<tr>
<td align=center><font size=5><div id='msg'></div></font>
</tr>
</table>
</body>
<script>
// Test 2 - attachEvent
// Works on IE8, IE9 and IE10
// Does not work on IE11
function onTestEvent(szType, szValue)
{
var MSG = document.getElementById("msg");
MSG.innerHTML = szType + " : " + szValue;
}
var elem = document.getElementById("testAxEvent");
elem.attachEvent("testEvent", onTestEvent);
</script>
</html>
Test 3 replaces attachEvent with addEventListener. Still the event is not triggered on IE11.
<!DOCTYPE html>
<html>
<head>
<title>TestEvent Example HTML</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<table>
<tr>
<td>
<OBJECT ID='testAxEvent' CLASSID='CLSID:BA19A985-C93E-491B-B801-2EB7F903C8CE' codebase="testAxEvent.cab" width='120' height='80'></OBJECT>
</td>
</tr>
<tr><td height='30'></td></tr>
<tr>
<td align=center><font size=5><div id='msg'></div></font>
</tr>
</table>
</body>
<script>
function onTestEvent(szType, szValue)
{
var MSG = document.getElementById("msg");
MSG.innerHTML = szType + " : " + szValue;
}
var elem = document.getElementById("testAxEvent");
// Test 3 - addEventListener
// Does not work on IE11 !
elem.addEventListener("testEvent", onTestEvent, true);
elem.addEventListener("testEvent", onTestEvent, false);
</script>
</html>