Home
Links
 
 
Home Page What is the Web 2.0 Web as a platform Netscape vs. Google DoubleClick vs. Overture and AdSense Akamai vs. BitTorrent Protection of web-services against a spam Server inclusions SSI (a part 1) Realiti Show of Creation of the Website Generation of the casual password What see search engines at call on a site? Visit cajt WebPosition Gold Construction of a site Contextual advertising. Modular structure of page Reception of heading of the removed page The script and processing of events in JavaScript Processing of the events connected to windows, in language javascript Concepts, terms and bases Java-skriptovanija
 

The script and processing of events in JavaScript

In javascript (or jscript, versions javascript firms microsoft) are two features: the first - that in him the functions are supported only, the second - that this language is clear for all browsers. The most habitual way of transfer of event to an element is an announcement of the name of function in tege an element. We shall notice, that we need to write down not simply "myclickcode", and " myclickcode () " for conformity of a syntactic design javascript. In html the document it will look so:



<h2 onclick = " myclickcode () ">

The text reacting to event

</h2>

...

<script language=javascript>

function myclickcode () {

alert (' you have clicked the Text! ');

}

</script>


It is good for job with separate elements and how to act{arrive} if necessary processings of events by the whole document? In this case indexes on obrabotchiki events can be placed in teg <body>:



<body onmousemove = " mymousemovecode () " onclick = " myclickcode ()>


Besides it is possible to connect a code of processing inside tega an element. Thus such design of language jscript is used:



<h2 language=jscript onclick = " alert (' you have clicked the Text! '); ">

The text reacting to event

</h2>


As jscript is the language of a browser determined by default, it is possible to lower{omit} attribute "language=jscript", having made a design of more compact:



<h2 onclick = " alert (' you have clicked the Text! '); ">

The text reacting to event

</h2>


And, at last, it is possible to create separate section <script> for each event which to us needs to be processed:



<h2 id=myheading> the Text reacting to event </h2>

...

<script language=javascript for=myheading event=onclick>

alert (' you have clicked the Text! ');

</script>