How To Activate The Script

Table of contents:

How To Activate The Script
How To Activate The Script

Video: How To Activate The Script

Video: How To Activate The Script
Video: Unity 5 C# How to activate or deactivate an script from another script 2024, April
Anonim

To make any script work, it needs to be called (activated) in some way. This can be done in several ways. Since such a task most often arises in relation to scripts used when working with hypertext pages, it makes sense to consider, first of all, ways to activate scripts in the most popular languages in this area - JavaScript, PHP, Perl.

How to activate the script
How to activate the script

Instructions

Step 1

If the script is written in any "client" language, then its execution, as a rule, does not require the installation and launch of special software. For example, JavaScript script files are loaded and stored on the user's computer along with the page in which they are embedded. To call (activate) such a script, find its file and double-click. However, it should be remembered that the script programmed calls to the elements of the page in which it is embedded. If you activate such a script separately from the page, then you may not see any signs of its work at all - it is better to do this by loading the "native" page of the script into the browser.

Step 2

If you need to activate the client script after loading the page into the user's browser, then its call can be tied to any event - pressing the button embedded in the page, hovering over an element, the expiration of the timer running when loading, etc. To do this, use the appropriate event attributes. Place a link to the script in the onClick attribute so that it will be activated on mouse click. Use the onFocus attribute if you want JavaScript to activate when the user starts filling out a field in a text input element. The onKeyDown and onKeyUp events will help to program the activation of the script when the key is pressed and released, onMouseOver - when the mouse cursor is hovering, onMouseOut - on the contrary, when the cursor is moved, etc.

Step 3

If you need to activate a server script (for example, in php or perl languages), then do it by typing its URL in the address bar. You can also program such a transition in the source code of the page in the usual way (by reference), or by binding it, as in the previous step, to an event. The server script cannot be launched if you simply download it and double-click it - such scripts are processed using special software. Therefore, to activate it on your personal computer, you need to install and run the appropriate set of programs - for example, the Denver kit (https://denwer.ru) can handle this.

Recommended: