• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1140
  • Last Modified:

Firefox does not handle Windows Media Player events


I want to use a windows media player in a web page, to be used in Firefox browser.
while all the controls' events are handled, the windows media player are not handled.
I used the following code :

<SCRIPT language="JavaScript" type = "text/JavaScript">
   var MediaPlayer = document.getElementById("MediaPlayer");
   if (MediaPlayer.addEventListener)
     MediaPlayer.addEventListener("click",function(e) {alert("click"); },true); // does not work
   if (window.addEventListener)
     window.addEventListener("click",function(e) {alert("click"); },true); //  works well.


<object id = "MediaPlayer" ...>
  <param = "..." value = "...">

I tried to install the media player plugin, but it didn't help.

Please tell me how to solve this problem.

  • 2
1 Solution
Michel PlungjanIT ExpertCommented:
Your code has to be after the object:

(code from http://www.captain.at/howto-addeventlistener-attachevent-parameters.php)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


<SCRIPT language="JavaScript" type = "text/JavaScript">
function initPage() {
  object = document.getElementById("MediaPlayer");
  if(window.addEventListener){ // Mozilla, Netscape, Firefox
        object.addEventListener('mouseover', testevent, false);
        object.addEventListener('click', testevent, false);
        object.myflag = "test";
        object.mydata = "123";
  } else { // IE
        object.attachEvent('onmouseover', testevent);
        object.attachEvent('onclick', testevent);
        object.myflag = "test";
        object.mydata = "123";

function testevent(evt){
      var e_out;
      var ie_var = "srcElement";
      var moz_var = "target";
      var prop_var = "id";
      // "target" for Mozilla, Netscape, Firefox et al. ; "srcElement" for IE
      evt[moz_var] ? e_out = evt[moz_var][prop_var] : e_out = evt[ie_var][prop_var];
      prop_var = "mydata";
      evt[moz_var] ? e_out = evt[moz_var][prop_var] : e_out = evt[ie_var][prop_var];

<body onLoad="initPage()">

<object id="MediaPlayer" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" type="application/x-oleobject"
        standby="Loading Microsoft Windows Media Player components..."
        width="320" height="67">
         <param name="url" value="http://members.aol.com/jrzycrim01/music/Bullethead.mp3">
         <param name="autostart" value="false">
         <param name="ShowStatusBar" value="true">
         <param name="volume" value="100">
          ActiveX is not installed or is not working properly.
          If you are using Firefox, please refer to the following Guide:
          <a href="http://forums.mozillazine.org/viewtopic.php?t=206213">

           Embedded Windows Media in Firefox

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now