Firefox does not handle Windows Media Player events

Posted on 2006-05-24
Last Modified: 2007-12-19

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.

Question by:MichaelMarom
    LVL 75

    Accepted Solution

    LVL 75

    Expert Comment

    by:Michel Plungjan
    Your code has to be after the object:

    (code from

    <!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="">
             <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="">

               Embedded Windows Media in Firefox

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now