JavaScript

Posted: June 8, 2012 in Uncategorized

JavaScript is now a very widely used programming language. Most of the time it is used on the web browser, for the purpose to add interactions on the websites. So let’s try to understand what JavaScript is and how it works? As I mention before this programming language is mainly designed for the web browsers, all the browser has to include an interpreter to execute the JavaScript code.

JavaScript is a scripting language, not an OOP language however it is an event-driven programming, it handles the events done, and for more information on the Event-Driven Programming you can read my post. For JavaScript, it deals with the pages of the website as Objects. Each object can include other and so on. In other and clearer words, each window includes the document for the webpage where it might contain images, form or multiple forms. In each form there are multiple fields, textboxes and so on. We call the previous the previous example DOM, Document Object Model.

Let me redefine DOM again, it is a framework for JavaScript that give it the capability to deal with each object in the document, and react to the events done on it without the need to load a new page or even reloading the page. I have made a small example using JavaScript in a web application:

<html
xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head
runat=”server”>


<title></title>


<script
type=”text/javascript”>


function changeproperty() {

document.getElementById(“txt”).innerHTML = “AIE”;

}


</script>

</head>

<body>


<form
id=”frm” runat=”server”>


<div>


<asp:Label
ID=”txt” runat=”server” Text=”this my text that will be converted”></asp:Label>


<button
name=”btxt” onclick=”changeproperty()”> Click Me!!</button>


</div>


</form>

</body>

</html>

 

What this code really does is changing the text of the label named txt to AIE on the click of the button named btxt.

And the result should be

To mention JavaScript was first developed by Netscape, and then was implemented in all the browsers. The point, after that each company started developed its own, you might find programming language called Jscript, Ecmascript, they are different implementation for JavaScript before being standardized by w3c. For more information I recommend you visit this website. If you are really interested to learn JavaScript I do recommend this website.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s