I have come across an issue in the code base I working with in IE11 specifically.
Other versions of IE allow me to listen to a specific event called 'OpenStateChanged' which is fired from Windows Media Player like so.
document.getElementById('video-player').attachEvent("OpenStateChanged",
(newState) =>
)
When running the code in IE11, I am getting the error Object doesn't support property or method 'attachEvent'
which I understand as it is no longer supported. So I have modified my code to check if you can use the newer addEventListener
.
if (document.getElementById('video-player').addEventListener)
document.getElementById('video-player').addEventListener("OpenStateChanged",
(newState) =>
console.log newState
#MediaOpen state
if newState == 13
//do stuff
)
else
document.getElementById('video-player').attachEvent("OpenStateChanged",
(newState) =>
#MediaOpen state
if newState == 13
//do stuff
)
This is alright, and it runs without throwing errors, however, the event handler function is never fired. I have noticed that things like onclick
get changed to click
, but I have seen no documentation on event names for Windows Media Player.
Syntax in coffeescript, can provide js alternative if required.