Firefox/IE Event Handling Differences - attaching an event

Posted on 2007-03-22
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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

734 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