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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:37:43+00:00 2026-06-13T08:37:43+00:00

Hello I have a pretty basic question about events in JS. Can I do

  • 0

Hello I have a pretty basic question about events in JS.

Can I do something like:

var myobj = { };
document.getElementById("myid").onmousemove = function (e) {
  myobj.e = e;
}

...

// called from function which will occure after onmousemove guaranteed
document.getElementById("info").innerHTML = myobj.e.type;

I need this for my game. I want to save event data and dispatch it later in update function of my game loop.

Okay. Here is jsfiddle.

<p id="info"></p><canvas id="can" width="400px" height="400px" style="border: 2px solid red"></canvas>

var my = { };
document.getElementById("can").onclick = function(e, custom) {
    my.e = e;
}
document.getElementById("can").onmouseover = function(e, custom) {
    my.e = e;
}
document.getElementById("can").onmouseout = function(e, custom) {
    my.e = e;
}
document.getElementById("can").oncontextmenu = function(e, custom) {
    my.e = e;
}
document.getElementById("info").innerHTML = my.e.type;

http://jsfiddle.net/cMPSS/3/

And it doesnt work.

  • 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-13T08:37:44+00:00Added an answer on June 13, 2026 at 8:37 am

    Yes, you could do something like this

    var myEvents = [];
    var myDiv = document.getElementById("myDiv");
    var infoDiv = document.getElementById("info");
    
    function logEvent(e)
    {
        e.preventDefault(); // prevent default behaviour if needed
        myEvents.push(e); // Store event info
    }
    
    myDiv.onmousemove = myDiv.onmousedown = myDiv.onmouseup = logEvent; 
    
    // Set a timer for looping through the events
    gameTimer = setInterval(function() {
        // Loop through events
        while (myEvents.length>0)
        {
            ev = myEvents.shift();
            // Display event info
            infoDiv.innerHTML = ev.type + " " + infoDiv.innerHTML; 
        }
    }, 100)​
    ​
    

    DEMO

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

Sidebar

Related Questions

I'm new to Objective C and have a pretty basic question. So I have
I knw its pretty basic question but I have just started reading it... I
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
hello i have this question i was trying to find a way to call
Hello I have a datatable that I would like to filter with a single
I have something pretty simple I want to do. I'm still working through all
I have some pretty basic C++ code: #include <iostream> #include <string.h> #include <msclr\/marshal_cppstd.h> #using
I have a xml like this: <a> <b>hello</b> <b>world</b> </a> <x> <y></y> </x> <a>
I have a pretty simple scenario. I have the following HTML: <h1>Hello</h1> <input type="button"
OK. I have a very long and pretty complicated function. It looks almost like

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.