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

  • SEARCH
  • Home
  • 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 5989243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:04:26+00:00 2026-05-22T23:04:26+00:00

This seems to work fine in Firefox but, in IE8 specifically (it may work

  • 0

This seems to work fine in Firefox but, in IE8 specifically (it may work in other version of IE), I have an issue where the event variable is lost.

There is an event (mousedown) that calls a function that stores a parameter set. One of the parameters is the event itself. The function that is called stores the parameters in global variables so they can be accessed by the function called in the settimeout.

Once it is executed, the function called by the set timeout no longer has access to the properties in the event variable. It is still recognized as an event object, but all the properties are reset.

I have tried using function references, using anonymous functions both using the globals and also passing them as parameters but nothing seems to be working. Any one have any ideas?

I know this is a little complicated so I setup a simple example that shows my issue here:
http://jsfiddle.net/fd8sk/

When you click ‘Fire now’ (which doesn’t use a settimeout), you get that the button click is a number. When you click the ‘Fire delay’, the button is now ‘Unknown’.

This is a pretty generic function that has a lot of parameters that aren’t always used so I’m hoping to avoid major refactoring of this. In my real example, the parameter that is the event in my issue case won’t be an event in other scenarios.

  • 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-22T23:04:27+00:00Added an answer on May 22, 2026 at 11:04 pm
    onmousedown="eventFired(event);"
    

    does something subtly different in the event model of IE<9 than it does in other browsers.

    In most browsers, the above works because onX inline event handlers receive an implicit argument-like local variable called event, which is a newly-minted Event object for each new event. This gets passed to the eventFired function and remembered for later use.

    In the legacy-IE event model, there aren’t separate event objects, only the window.event property, which there’s only ever one of, one which returns details of the current event being handled. When you refer to event in an inline event handler attribute, you’re getting that property as a global variable, and not a newly-spawned instance as a local argument. This gets passed to the function and remembered, but only the object is remembered and not its values. Later on, when the object is re-used, its properties reflect the new event being handled (if any), not the old.

    So remember only the particular property value you’re interested in keeping instead of the event object. I’d also avoid using inline event handler attributes as there are so many gotchas with them.

    <input type="button" id="fire-now" value="Fire now" />
    <input type="button" id="fire-delay" value="Fire delay" />
    <script type="text/javascript">
        document.getElementById('fire-now').onclick= function(e) {
            e= e || window.event;
            alert(event.button);
        };
        document.getElementById('fire-delay').onclick= function(e) {
            e= e || window.event;
            var button= e.button;
            setTimeout(function() {
                alert(button);
            }, 1000);
        };
    </script>
    

    Note that this isn’t the end of your cross-browser worries as IE<9’s button property has different values to the standard MouseEvent buttons!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hover seems to work fine in Firefox, safari..but not in IE. How to fix
This seems to work fine in C#: class A : System.Attribute { public A()
This seems in my head like it should work but I cant figure out
This seems painfully simple, but I can't work out how to do it: I
Ok this seems so silly but I'm having some trouble getting this to work.
This evaluation in sql doesn't seems to work properly for some reason but i
This one seems to be a simple problem, but I can't make it work
I have a pair of nested tables which seem to work fine in Firefox,
See this link: http://lsp2.tpdserver2.co.uk/test.htm Displays fine in IE/Chrome but in Firefox (6.0.1) there is
i have some jquery code here that works fine in firefox but when i

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.