Podcast
Questions and Answers
Which event occurs when a mouse button is pressed?
Which event occurs when a mouse button is pressed?
- onmousemove
- ondblclick
- onmousedown (correct)
- onmouseover
What event is triggered when an element loses focus?
What event is triggered when an element loses focus?
- onchange
- onfocus
- onselect
- onblur (correct)
Which event occurs when the user exists the page?
Which event occurs when the user exists the page?
- onunload (correct)
- onload
- onerror
- onabort
What event is triggered when a keyboard key is released?
What event is triggered when a keyboard key is released?
Which event occurs when an image is finished loading?
Which event occurs when an image is finished loading?
What event is triggered when a window or frame is resized?
What event is triggered when a window or frame is resized?
Which event occurs when the reset button is pressed?
Which event occurs when the reset button is pressed?
What event is triggered when the content of a field changes?
What event is triggered when the content of a field changes?
What is the primary purpose of the script tag in HTML?
What is the primary purpose of the script tag in HTML?
What is the language attribute of the script tag used for?
What is the language attribute of the script tag used for?
What is the purpose of the type attribute in the script tag?
What is the purpose of the type attribute in the script tag?
Where can script code be placed in an HTML page?
Where can script code be placed in an HTML page?
How many scripts can be added to an HTML page?
How many scripts can be added to an HTML page?
What is the output of the document.write() function in the given program?
What is the output of the document.write() function in the given program?
What is the purpose of the document.write() function?
What is the purpose of the document.write() function?
What is the difference between the two document.write() statements in the given program?
What is the difference between the two document.write() statements in the given program?
Study Notes
Mouse Events
onclick
: triggered when a mouse click occurs on an objectondblclick
: triggered when a mouse double clicks on an objectonmouseover
: triggered when a mouse cursor hovers over an objectonmousedown
: triggered when a mouse button is pressedonmousemove
: triggered when a mouse is movedonmouseout
: triggered when a mouse is moved out of an elementonmouseup
: triggered when a mouse button is released
Keyboard Events
onkeydown
: triggered when a keyboard key is pressedonkeypress
: triggered when a keyboard key is pressed or held downonkeyup
: triggered when a keyboard key is released
Form Events
onfocus
: triggered when an element receives focusonblur
: triggered when an element loses focusonchange
: triggered when the content of a field changesonselect
: triggered when text is selectedonreset
: triggered when the reset button is pressedonsubmit
: triggered when the submit button is clicked
Window Events
onload
: triggered when a page or an image is finished loadingonunload
: triggered when the user exits the pageonerror
: triggered when an error occurs while loading a document or an imageonabort
: triggered when loading an image is interruptedonresize
: triggered when a window or frame is resized
HTML Script Tag
- The HTML script tag is used to add script code inside an HTML page.
- The script tag contains two attributes: language and type.
Script Attributes
- Language Attribute: represents the name of the scripting language, such as JavaScript or VBScript.
- Type Attribute: indicates the MIME (Multi-Purpose Internet Mail Extension) type of the scripting code.
Location of Script
- Script code can be placed in both the head and body sections of an HTML page.
- Multiple scripts can be located in both the head and body sections of a page.
Example of Scripting in Head and Body Section
- We can create unlimited number of scripts inside the same page.
- Example of multiple scripts in head and body section:
Script code here
Script code here
Program Example
- An example program that uses
document.write()
to print a message:
document.write("Hi my name is JavaScript")
- Another example program that uses
document.write()
to print a different message:
document.write("Hello my name is Web System")
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz tests your understanding of different JavaScript events, including onclick, ondblclick, onmouseover, and more. Identify the correct event trigger for each scenario.