Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Firefox/IE Event Handling Differences - attaching an event

Posted on 2007-03-22
Medium Priority
Last Modified: 2008-01-09
I have some code which works in IE, but the event does not get attached in Firefox. Any ideas as to the equivalent in Firefox?

<script language="javascript">

document.getElementById('Player1').attachEvent('PlayStateChange', GetPlayState);

function GetPlayState()
            if (document.getElementById('Player1').playState==8)

Question by:fsbsupport
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Cyber-Drugs earned 2000 total points
ID: 18771709
You need addEventListener('click', myfunction, false)

Expert Comment

ID: 18771714
Extra information on the subject can be found here:
LVL 15

Expert Comment

ID: 18773068
Do it like this (via Scott Andrew)

function addEvent(elm,evType,fn,useCapture) {
     if (elm.addEventListener) {
          elm.addEventListener(evType, fn, useCapture);
          return true;
     } else if (elm.attachEvent) {
          var r = elm.attachEvent('on' + evType, fn);
          return r;
     } else {
          elm['on' + evType] = fn;

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

671 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