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 8228249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:24:05+00:00 2026-06-07T16:24:05+00:00

for some purpose i want to cache the Window.Event object in a variable and

  • 0

for some purpose i want to cache the Window.Event object in a variable and use it later,but MSIE keep telling me that this is ‘unknow’.

just run the code below in IE,you will see what i mean

i just want to ask how can this happen?
did i miss something?

html:

<button id='btn'>Click!!!</button>

JS:

    var eventObj = null;
    document.getElementById('btn').onclick = function() {
       eventObj = window.event;
       setTimeout(function() {
          alert(typeof eventObj.srcElement);
       }, 1000)
    }​

EIDT 1:

i have search some test done by other ,see the below:

HTML :

<button id='btn1'>Click 1 !!</button>
<button id="btn2">Click 2 !!</button>

JS

var btn1EventObj = null;
document.getElementById('btn1').onclick = function() {
    btn1EventObj = window.event;
    alert(btn1EventObj.srcElement.id);
}
document.getElementById('btn2').onclick = function() {
    alert(btn1EventObj === window.event); // output:false;
    alert(btn1EventObj.srcElement === window.event.srcElement); // output: true ; 
    alert(btn1EventObj.srcElement.id); // output: btn2 ;
}

when the btn1 has been click i assume i cache the ‘event object’ in the btn1EventObj,and then click the btn2:

test:

btn1EventObj === window.event -> false; // there is not only one event object in MSIE

btn1EventObj.srcElement === window.event.srcElement -> true // i can not understand this one the the below.

btn1EventObj.srcElement.id ->btn2

see the fiddle

so all the above tell me that maybe all the event raised in MSIE are all share attributes ,and when the btn2 is clicked,all the previous attribute are overwrite by the later one?

am i kind of right ?

  • 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-06-07T16:24:07+00:00Added an answer on June 7, 2026 at 4:24 pm

    You can’t copy window.event out of context of the actual event in IE. In other words: there is no existing event when you assign the handler in the script. If you want to refer to the window.event, the handler has to be assigned inline.

    MSDN:

    The event object is available only during an event—that is,
    you can use it in event handlers but not in other code.
    

    HTML:

    <button id='btn' onclick="clicker(event);">Click!!!</button>
    

    and JS:

    function clicker(e){
        setTimeout(function (){
            alert(e.srcElement);
        },1000);
        return;
    }
    

    event in MSDN.

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

Sidebar

Related Questions

I have some views that I want to use EF 4.1 to query. These
I'm trying to write simple proxy server for some purpose. In it I use
Is there some valid purpose to minifying before compressing? It seems highly unlikely that
I'm currently writing some general purpose .net libraries that contain usual helper classes. For
I want to write some values to an external file and use NSDictionary for
I want to write a program in Objective-c that grabs some sports stats off
For performance purposes, I want to have some of my web pages use resources
I want to do some drawing of NSAttributedStrings in fixed-width boxes, but am having
I want to create some PHAR Archives but did not find any good alternative
That is a common question, but I would like to hear some expert opinions.

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.