🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

JavaScript Events
16 Questions
0 Views

JavaScript Events

Created by
@AmusingModernism

Podcast Beta

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which event occurs when a mouse button is pressed?

  • onmousemove
  • ondblclick
  • onmousedown (correct)
  • onmouseover
  • What event is triggered when an element loses focus?

  • onchange
  • onfocus
  • onselect
  • onblur (correct)
  • Which event occurs when the user exists the page?

  • onunload (correct)
  • onload
  • onerror
  • onabort
  • What event is triggered when a keyboard key is released?

    <p>onkeyup</p> Signup and view all the answers

    Which event occurs when an image is finished loading?

    <p>onload</p> Signup and view all the answers

    What event is triggered when a window or frame is resized?

    <p>onresize</p> Signup and view all the answers

    Which event occurs when the reset button is pressed?

    <p>onreset</p> Signup and view all the answers

    What event is triggered when the content of a field changes?

    <p>onchange</p> Signup and view all the answers

    What is the primary purpose of the script tag in HTML?

    <p>To embed a script code inside an HTML page</p> Signup and view all the answers

    What is the language attribute of the script tag used for?

    <p>To indicate the name of the scripting language</p> Signup and view all the answers

    What is the purpose of the type attribute in the script tag?

    <p>To specify the MIME type of the script code</p> Signup and view all the answers

    Where can script code be placed in an HTML page?

    <p>In both the head and body sections of the HTML page</p> Signup and view all the answers

    How many scripts can be added to an HTML page?

    <p>Unlimited number of scripts can be added to an HTML page</p> Signup and view all the answers

    What is the output of the document.write() function in the given program?

    <p>Hi my name is JavaScript</p> Signup and view all the answers

    What is the purpose of the document.write() function?

    <p>To write output to the page</p> Signup and view all the answers

    What is the difference between the two document.write() statements in the given program?

    <p>The first one writes 'Hi my name is JavaScript' and the second one writes 'Hello my name is Web System'</p> 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.

    Quiz Team

    Description

    This quiz tests your understanding of different JavaScript events, including onclick, ondblclick, onmouseover, and more. Identify the correct event trigger for each scenario.

    More Quizzes Like This

    HTML Events and JavaScript
    18 questions

    HTML Events and JavaScript

    RemarkableSaxophone avatar
    RemarkableSaxophone
    Eventos y Escuchas en JavaScript
    6 questions
    Use Quizgecko on...
    Browser
    Browser