Podcast
Questions and Answers
Which event occurs when a mouse button is pressed?
Which event occurs when a mouse button is pressed?
What event is triggered when an element loses focus?
What event is triggered when an element loses focus?
Which event occurs when the user exists the page?
Which event occurs when the user exists the page?
What event is triggered when a keyboard key is released?
What event is triggered when a keyboard key is released?
Signup and view all the answers
Which event occurs when an image is finished loading?
Which event occurs when an image is finished loading?
Signup and view all the answers
What event is triggered when a window or frame is resized?
What event is triggered when a window or frame is resized?
Signup and view all the answers
Which event occurs when the reset button is pressed?
Which event occurs when the reset button is pressed?
Signup and view all the answers
What event is triggered when the content of a field changes?
What event is triggered when the content of a field changes?
Signup and view all the answers
What is the primary purpose of the script tag in HTML?
What is the primary purpose of the script tag in HTML?
Signup and view all the answers
What is the language attribute of the script tag used for?
What is the language attribute of the script tag used for?
Signup and view all the answers
What is the purpose of the type attribute in the script tag?
What is the purpose of the type attribute in the script tag?
Signup and view all the answers
Where can script code be placed in an HTML page?
Where can script code be placed in an HTML page?
Signup and view all the answers
How many scripts can be added to an HTML page?
How many scripts can be added to an HTML page?
Signup and view all the answers
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?
Signup and view all the answers
What is the purpose of the document.write() function?
What is the purpose of the document.write() function?
Signup and view all the answers
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?
Signup and view all the answers
Study Notes
Mouse Events
-
onclick
: triggered when a mouse click occurs on an object -
ondblclick
: triggered when a mouse double clicks on an object -
onmouseover
: triggered when a mouse cursor hovers over an object -
onmousedown
: triggered when a mouse button is pressed -
onmousemove
: triggered when a mouse is moved -
onmouseout
: triggered when a mouse is moved out of an element -
onmouseup
: triggered when a mouse button is released
Keyboard Events
-
onkeydown
: triggered when a keyboard key is pressed -
onkeypress
: triggered when a keyboard key is pressed or held down -
onkeyup
: triggered when a keyboard key is released
Form Events
-
onfocus
: triggered when an element receives focus -
onblur
: triggered when an element loses focus -
onchange
: triggered when the content of a field changes -
onselect
: triggered when text is selected -
onreset
: triggered when the reset button is pressed -
onsubmit
: triggered when the submit button is clicked
Window Events
-
onload
: triggered when a page or an image is finished loading -
onunload
: triggered when the user exits the page -
onerror
: triggered when an error occurs while loading a document or an image -
onabort
: triggered when loading an image is interrupted -
onresize
: 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.