Jump to content

Wikipedia:Reference desk/Archives/Computing/2017 February 14

From Wikipedia, the free encyclopedia
Computing desk
< February 13 << Jan | February | Mar >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


February 14

[edit]

Javascript events and responses

[edit]

As a fresh Javascript student I concluded these statements. I ask to have an expret's take on this, to know if all are true:

  1. All events are HTML based, but never base on Javascript by itself (Js uses us to create responses to events, but not the events themseleves).
  2. Events can be based on HTML attributes and their values (as in [href="http://www.example.com"] or [type="submit"].
  3. Some HTML tags (like <html>, <body> or <form>) have events unique to them, like onload for <html> and <body>, or onsubmit for <form>.
  4. Pseudo events can be based on CSS pseudo classes, as in :hover. These are called pseudo events because they are not events that can be further manipulated with Javascript.
  5. Some event responses are builtin in HTML. For example, when a client clicks a link created with an ahref attribute and moves to another location on the window, without Js intervention.
  6. Some event responses, even if exactly similar to HTML builtin ones, can be created with Js. For example - click, window.location will also move the client to another location on the window, without HTML ahref attribute intervention.
  7. When responding with Javascript, we listen to events on a specific element with the builtin method addEventListener, and we define the response in an event handler. 78.55.201.151 (talk) 07:58, 14 February 2017 (UTC)[reply]


Okay, here we go.
  1. Roughly yes, though not exactly. Look at built-in functions like setTimeout() and setInterval() both provide you with ways to trigger function calls when a condition that does not rely upon any HTML construction is true. The way those functions are handled is the same way events are handled (because otherwise, you would be stuck at those function calls, unable to proceed further into the code until they finished, which might never happen with a setInterval() call). You can also define and raise custom events within javascript. So if this is a test question in an entry level course, you can say "Yes" but if you're just trying to learn, then the answer is "not really."
  2. It can also interact with the browser itself in limited ways and certain (very limited) aspects of the operating system.
  3. Yes.
  4. AFAIK, "pseudo events" is not the formal name of any set of events, but a term which is used loosely and in different ways in different situations. The CSS :hover is a selector; it does not rely on javascript at all. In JQuery (an implementation of JS designed for styling and constructing interactive multimedia web sites) there is a hover() event that allows you to call a jquery (or javascript) function on mouse hover.
  5. Yes. HTML handles some events, though this is rarely referred to as such as they are not coded in the same way that traditional event-driven code is. HTML5 actually has quite a bit of interactivity.
  6. Yes. This is true of almost any multi-language environment. Any Turing complete programming language will allow you to replicate any functionality possible on a computer (with no promises made as to how easy it will be to do so).
  7. Yes.
Hope this helps. ᛗᛁᛟᛚᚾᛁᚱPants Tell me all about it. 13:49, 14 February 2017 (UTC)[reply]
Very much! Thank you so much! Ben. 77.180.115.74 (talk) 22:52, 15 February 2017 (UTC)[reply]