Events are facts that occur during system implementation, from which the programmer can define actions to be performed by the program. Below is the list of possible events in Javascript, indicating the times when they may occur as well as the subject of its occurrence objects:


  • onload – Occurs in charge of the document. That is, only occurs in the BODY of the document;
  • onunload – occurs in the discharge (output) of the document. Also only occurs in the BODY;
  • onchange – Occurs when the object loses focus and there was a change of content. Valid for objects Text, Select and Textarea;
  • onblur – Occurs when the object loses the focus, irrespective of the existence change. Valid for objects Text, Select and Textarea;
  • onfocus – Occurs when the object receives focus. Valid for objects Text, Select and Textarea;
  • onclick – Occurs when the object receives a Click of the Mouse. Valid for Buton objects, Checkbox, Radio, Link, Reset and Submit;
  • onmouseover – Occurs when the mouse pointer passes over the object. Only valid for Link;
  • onselect – Occurs when the object is selected. Valid for Text and Textarea objects;
  • onsubmit – Occurs when a Submit type button receives a click of the mouse. Only valid for the Form.


JavaScript allows the programmer to write lines within a page (document) through the write method. The lines written in this way, can contain text, HTML and JavaScript expressions commands. The lines written by this method will appear on the screen point where the command is entered. For example:



value = 30

document.write (“My first line <br>”)

document.write (“This line appears the result of” +

(10 * 10 + value))

</ script>


The idea of ​​the above example is to write two lines. To prevent the two lines are written on the same line is used to HTML tag to make a line break. When writing a document is required, then the use of another essential feature: the functions.

A function is an instruction set, which should only be performed when the function is activated. The general syntax is as follows:

function functionName (parameters) {Action}

Suppose a function that aims to inform if a person is more or less old, receiving as parameter the age:

function Age (Years) {

if (Years> 17) {

alert (“Greater Age.”)

} Else {

alert (“Minor Age.”)




To activate this function, suppose a text box on a form, in which the old is informed, and every information, the function is triggered.


<input type = text size = 2 maxlength = 2 name = “Time” onchange = “Age (Time.value)”>

</ form>

Note that the last parameter (when the event “onchange” occurs) was the contents of the text box “Time” (property “value”) and that in the function we call “Years”. I.e., there is no correlation between the name of the variable passed and receiving variable in the function. Only the content is passed.

Visit our blog and check out more content!

By ,

February 22, 2016


You might also like…

Business Process Automation with Scriptcase

In the modern business world, operational efficiency is not just a goal. It's a necessity. With inc...

“We developed RISK4ALL, a SaaS platform that allows implementing GRC in an organization with total security and privacy.” (RISK4ALL)

Come and discover the success case of the Risk4all, software, a multilingual and multi-company SaaS...

Security in web applications

In this article, you will learn about web application security and the options within Scriptcase th...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.