Level 41 Level 43
Level 42

[Quiz] Events

78 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

triggered when the user changes focus to a different form field
The user changed the object in some way
HTML DOM mouse events?
triggered when the user sets focus to a form field
web browser finished loading a page
triggered when the mouse cursor is located over a form field
triggered when the mouse cursor leaves the form field
The user submitted an HTML form
The browser unloaded a page from memory
Do we generate events?
we do not create events. events has already been created. we can only use them. e.g. check box generate on click event.
_______ can be used to mean 'any character that is not a newline'
When do we use event handlers?
When we want to run some JavaScript on certain conditions. e.g. when a link is clicked on the page.
Tell us an couple of examples when we need event handlers?
Only want to run some JavaScript when a link is clicked on the page.
What is an event actually?
The events are already happening. They've been happening all along.
What represents events in JS?
these events are built into JavaScript. they are represented by built in properties (variables belonging to an object) They're part of JavaScript, and there are special words to describe them.
we use them with objects.
What do we use event variables with?
What do events usually start with?
onload onclick onmouseover onblur onfocus many more
Do we write the event itself? Maga´t az eseme´ny i´rjuk meg?
no we do not.we write what's called the event handler or the event listener, whatever term you prefer.
What is the difference between a user-defined object or a object constructor
How many ways can you react to an event in JS?
I'm going to talk about and cover three ways you can react to an event in JavaScript.
element.event =
What is the second way to write an event?
What does window.onload mean?
So window.onload means the onload event of the window object;
What does nameField.onblur mean?
nameField.onblur means the onblur event of the nameField object;
What does myElement.onlick mean?
if sy clicks on my element it will be activated.
What is an event handler?
A function that is called with a certain event occurs. Examples of these include button.onclick and window.onload.
What format do we use for event handlers?
Csak bizonyos felte´tel teljesu¨le´se esete´n kapja meg a va´ltozo´ a functiont. e´s eze´rt csak akkor kerul ve´grehajta´sra.
What is an anonymous function?
A function without a function name.
we use anonymous function.
What kind of function do we use with event handlers?
Why do we not have to give a name to anonymous function?
we don't have to give it a name because we're saying exactly when this gets executed, which is when they click my element. So when this event happens, we want to run this function, what…
What will JS will do when it reads an event handler and a function belonging to it?
it won't actually do anything with the function. What you're actually saying is later on when the user clicks this element, we execute this code.
because the whole things is a statement and after every statement you have to use a semi-colon.
it uses the addEventListener
What method does the third way use?
Can you call it on the document object and on other elements as well?
you can either call addEventListener method directly on the document object or on any element that you have.
And you give it three pieces of information:
How many pieces of information do we have to give as an argument?
What are those?
the event without the word on--and here you actually write it without the word on, so click rather than onclick, mouseover rather than onmouseover—
What event are we listening for.
What do we refer to by event?
What do we refer to by function?
what function gets called when it happens
What is the benefit of using addEventListener method?
you can actually add a listener to multiple events You can add one event and have multiple listeners. you can remove event listener while JS is running.
removeEventListener method
What is the mirror image of addEventListener method?
What is removeEventListener method for?
you can remove event listeners when JS is running.
What is the disadvantage of addEventListener method?
This is one of the very few areas left where there is still a difference between the browsers.
What is the issue with Internet Explorer?
Internet Explorer, prior to IE 9, does not have the addEventListener function.
yes it does.
Does it have any alternatives?
What is it?
It has its equivalent which is the attachEvent method,
it takes two parameters.
How many parameters does it take?
What are those parameters?
Same idea; it's the event name itself and then the function.
How does attachEvent method differs from addEventListener?
they do not differ from each other. but their names are different.
How can we solve this problem?
we now need to write code to detect whether or not these functions exist.
When do we not use () after a method or function?
we do not use () after a function when do not call it. we only assign it to a variable or checking with an if statement if it is set.
var a = "alma"; if (a) {
How do we test if a variable has a value?
When will the assignment be carried out when we assign an anonymous function to an event?
if we assign an anonymous function to an event handler then the assignment will be carried out only when the user creates an event.
a semi-colon.
What do we have to use after the function?
addEventListener method
What is the third way to use event handlers?
three pieces of information:
How many pieces of information do we have to give as an argument?
What is false for ?
This third false argument is an option for some super-advanced event handling that's very unusual to need.
How do you do that?
you can use the same code and use the same listener but use different functions. this way multiple events will occur when the event is triggered.
Why is jQuery used most of the times ?
it provides excellent cross-browser functions for situations
what is the javascript event object?
The event object gives you information about an event that has occurred.
what does the event object represent?
The Event object represents the state of an event
JavaScript treats _______ as first-class objects.
when are functions triggered?
not until the event occurs
An element loses focus
when does the onblur event occur?
when does the onchange event occur?
The content of a field changes
Mouse clicks an object
when does the onclick event occur?
Mouse double-clicks an object
when does the ondblclick event occur?
when does the onerror event occur?
An error occurs when loading a document or an image
An element gets focus
when does the onfocus event occur?
A keyboard key is pressed
when does the onkeydown event occur?
when does the onkeypress event occur?
A keyboard key is pressed or held down
A keyboard key is released
when does the onkeyup event occur?
A mouse button is pressed
when does the onmousedown event occur?
The mouse is moved
when does the onmousemove event occur?
when does the onmouseout event occur?
The mouse is moved off an element
when does the onmouseover event occur?
The mouse is moved over an element
A mouse button is released
when does the onmouseup event occur?
when does the onresize event occur?
A window or frame is resized
Text is selected
when does the onselect event occur?
The user exits the page
when does the onunload event occur?