Archive | Java Script RSS feed for this section

Introduction to Javascript for Newbies

24 Jan

Javascript is a client-side programming language whose processing engine is embedded in web browsers like Internet Explorer, Netscape, Firefox, etc. This enables the processing engine to read and interpret web pages that contain the javascript code when browsing.

Javascript first made an appearance in 1995, although by that time it was known as Livescript. This name was later changed to javascript.

Javascript was invented to add more exciting features to HTML pages. HTML on it’s on is pretty boring and it cannot do much besides display a webpage. Javascript programming, on the other hand, can provide a host of exciting features like perform calculations, allows the user to interact with webpages, perform form validations, manipulate elements on a webpage, provide excellent visual effects, enables dynamic functions and so much more.

All of this provides the user to the site with an enhanced user experience. Because javascript is a client-side language, all of these features are available in real time without the browser having to refer to the server all the time. This prevents time delays and increases user satisfaction.

Let’s take a closer look at the great things you can do with javascript programming:

Perform Calculations

Javascript can be used to perform simple to advanced mathematical calculations. This is especially useful if you want your users to interact with your site by inputting some information that requires some sort of calculation and displaying the relevant content based on that result. For example, javascript can calculate a loan repayment and display the appropriate result if a user enters a required loan amount on the site. Furthermore, javascript can also tell date and time, time a certain activity and perform intricate date and time calculations.

User Interaction

The javascript on the webpage can take interaction from a user and perform a certain function by way events. Some of the most popular events are:

onblur
onchange
onclick
ondblclick
onfocus
onkeydown
onkeypress
onkeyup
onload
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
onselect
onsubmit

Perform Form Validations

Javascript can validate and check user input to determine whether it conforms to a certain requirement. For example, you can check if a field is left empty, if an email address is in the proper format, if a zip code code is in the proper format, etc. In most cases, if an error is made by your site visitor, an alert can display the appropriate error message to him or her.

Manipulate Elements On A Webpage

Javascript allows a user to change content or styles of a webpage upon a user interaction by way of the aforementioned events. For example, hovering over a certain text can make an image appear, text on a submit button can change on submit, etc.

Provide Visual Effects

Javascript has a host of ways to provide visual effects to a webpage that other server-side programming languages cannot. A typical example of this might be some fancy image rollover buttons.

Enables Dynamic Functions

Javascript, together with AJAX (asynchronous JavaScript and XML), can be used to create dynamic applications. One example of this is to load dynamic content onto a webpage without refreshing the page.

In my next chapter, we will delve further into javascript programming.