Concepts, terms and bases Java-skriptovanija
In clause{article} the basic terms and concepts skriptovykh languages are briefly explained (in particular, javascript), are described the basic receptions of programming on javascript, and also are resulted a little simple, but useful examples of which practical application is possible to find.
In the first, it is not necessary to confuse javascript and java are two big differences!
java is a powerful platformo-independent programming language of a high level which has ample opportunities for use in the Internet because of the functionality, simplicity and safety. But he is used as otkompilirovannykh applications - applets or java webs - services, as against javascript.
javascript is skriptovyj language, that is the programming language in which there are no system functions, organichennyj access to file system (with a view of safety) and which is not compiled, and is processed by the special interpreter which has been built - in everyone sovremmennyj a browser (the truth, realization of it{him} not everywhere is identical, that results in the big headache of web designers, but about it later).
This language has been developed by firm netscape, hence, the first javascript began to support ikhnij navigator. Then it{him} has joined as well mikrosoftovskij internet explorer, in realization of which objective model his{its} founders, certainly, have added some own features.
javascript is very convenient means for realization of functional and convenient webs - pages with the feedback, reacting on actions of the user. It is possible to create nice menus with "overturned" items - pictures (you for certain saw such on what - nibut` site), to insert on page such useful elementy, as hours, a calendar, even the calculator (it is useful on what - nibut` financial site, or Internet - shop).
In a basis of functionality javascript lays so-called dom (from document object model, objective model of the document).
This model stores{keeps} the whole heap of properties of web - page and a window of a browser in an objective kind. It, for example, such properties as color of a background of page, the address of the document, in separate collections (files) all figures (images) and anchors - links (anchors) pages are stored{kept}.
To change or still somehow to affect these properties it is possible with the help of methods (or functions) - for example:
document.write (" hello? world!!! ");
Here it is used a function - method write object document for a conclusion of the message to page. It only the elementary example of use of methods.
The method is a member of any object which carries out what or actions with object, similarly to functions.
The special attitude{relation} in javascript to variables - in this language no the strict control of types. At the announcement of a variable the carrying out environment automatically defines{determines} its{her} type on inicializirujuhhemu to value. That is, if the variable appropriates{gives} numerical value, the type of a variable is defined{determined}, how int (integer value) or float (fractional from a floating point). Hence...
In javascript there is no strict typification of variables.
Despite of these simplifications, on javascript it is possible to write rather functional programs which can simplify to visitors job with your site. Now some educational examples.
Processing of events
In language javascript there is such way of a spelling of programs, as processing of events, that is performance of any functions in reply to event.
Event (event) - is generated in reply to some actions of the user or the environment of performance (a window of a browser, a status of the document)
Using this reception, it is possible to allocate, for example, active elements on page by means of change of color of an element:
function change_color (element, color) {
// It is caused in reply to prompting of the cursor of the mouse:
//
//....... //
element.style.color = color;
}
But not necessarily to change color. javascript allows to do{make} still very much much with elements of the document.

© Web Development Company Conkurent, LLC 2008-2009. All rights reserved. |