How to activate a script

How to activate a script

To force to work any script, it is required somehow to cause to be (activated). It is possible to make it in several ways. As such task most often arises in relation to the scripts used during the work with hypertext pages that is to consider sense first of all ways of activation of scripts in the languages, most popular in this area, - JavaScript, PHP, Perl.

Instruction

1. If the script is written in any "client" language, then execution it, as a rule, does not require installation and start of the special software. For example, files of the JavaScript-script are loaded and saved in the user's computer together with the page which they are built in. For a call (activation) of it scripts find its file and double click a mouse. However it is necessary to remember that in a script accessing elements of the page which it is built in is programmed. If to activate such script separately from the page, then it is possible not to see any signs of its work at all - better to do it, loading the "native" page of a script into the browser.

2. If it is required to activate a client script after loading of the page in the user's browser, then his call can be tied to any event - clicking of the button which is built in the page, guidance of the cursor any element, the expiration of time of the timer started when loading, etc. For this purpose use the attributes corresponding to an event. Place the link to a script in the onClick attribute that it was activated at mouse click. Use the onFocus attribute if it is required to activate the JavaScript-script when the user begins filling of any field in a text entering element. Events of onKeyDown and onKeyUp will help to program activation of a script during the clicking and release of a key, onMouseOver - at mouseover, onMouseOut - on the contrary, at withdrawal of the cursor, etc.

3. If it is required to activate a server script (for example, in the PHP or perl languages), then make it, having gathered its URL in an address bar. It is possible and program such transition in the source code of the page in the normal way (link), or having tied him, as well as in the previous step, to any event. The server script will not manage to be started if it just to download and double-click - such scripts are processed by means of the special software. Therefore for activation it on your personal computer it is necessary to install and start the corresponding set of programs - for example, the set of Denver (http://denwer.ru) can cope with it.

Author: «MirrorInfo» Dream Team


Print