Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4058434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:04:45+00:00 2026-05-20T15:04:45+00:00

Only today I figured out how event propagation works and set out pompously to

  • 0

Only today I figured out how event propagation works and set out pompously to test it on my existing code base but arghhhhhhh damn you javascript……nothing seems to be simple enough with you :X

Here is my problem, I define a set of events on an anchor:

theLink.setAttribute('onMouseOver','doSomething(this)');    **// works**

theLink.addEventListener("mouseout", function(event){doSomethingElse(event)}, false);  **// does not work**

theLink.onmouseout = function(event){doSomethingElse(event)};     **// does not work**

Only if I define events as in the first example then it seems to be working in the second or the third definitions as well. But I can not use that definition because I have to pass event object.

Any hints? I am using firefox.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:04:45+00:00Added an answer on May 20, 2026 at 3:04 pm

    All three of these worked for me using the following code (in firefox):

    HTML:

    <a id="link1">Link 1</a>
    <a id="link2">Link 2</a>
    <a id="link3">Link 3</a>
    

    JS:

    var link1 = document.getElementById("link1");
    var link2 = document.getElementById("link2");
    var link3 = document.getElementById("link3");
    
    window.doSomething = function(event) {
        console.log(event);
    }
    
    link1.setAttribute('onMouseOver', 'doSomething(this)');
    
    link2.addEventListener("mouseout", function(event) {
        doSomething(event)
    }, false);
    
    link3.onmouseout = function(event) {
        doSomething(event)
    };
    

    Here is a jsfiddle with it working: http://jsfiddle.net/magicaj/qk6wU/

    You might also consider using a library like jQuery that handles cross browser incompatibility with the addEventListener method that is not supported by some versions of IE, the JS would look something like this:

    $("#link1").mouseover(doSomething);
    $("#link2").mouseover(doSomething);
    $("#link3").mouseover(doSomething);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started to learn about Mockito only today. I wrote some simple test (with
Before I ask my question, I want to mention that I am only today
On uploading my App onto the market today, I saw that it is only
I am trying to select records from a database only if they match today's
I am trying to return twitter titles based on today's date only. I have
Only editor can post into database but the price could'nt Post into database.. So,
Maybe I'm not all there today, but I'm wondering how to get this to
I already asked a question today : This one Now I have a code
I figured out how to create a bookmarklet for Google Analytics that opened to
This is 'sorta' urgent since my app just went live today. My app works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.