Script Scrap

Exploring the languages in the web of technology


Javascript is the most common scripting language of the web. Javascript adds motion and interaction to web pages. It also provides for dynamic content to be added to the page while you are viewing it.

Javascript is located between <script> tags. It is designed to avoid interfering with the user if there is an error. Consequently, if anything is wrong on the page it does not run. It does not give an error anywhere ‐ it simply pretends that there is no javascript on the page. This can be very frustrating to a new user. The only way to debug it is to comment out large sections of your code and check the remainder step by step. This can be very time consuming.

Javascript is started with an event. This can be a user click, a page opening or closing, a mouse moving, or a timer running out. as soon as this code is run the page stops and waits for another event to happen.

Things like buttons often have javascript behind them.

Events run functions. each function can be given arguments, can have variables inside, and can return a value as well as modifying the page. Often the best way to determine whether a function is working correctly is to examine the output to see if it gave the expected result.

<script type="text/javascript">
  function sayhello() {
    alert("Hello, welcome to the world of javascript!");

Or you can make programs that utilize user input:

<script type="text/javascript">

function factorial() {
  for(z=x;z>=1;z--) {
  alert("the factorial of "+x+" is "+y);

Choose an integer to see its factorial.

There are many other functions in javascript. A lot of them are similar to functions in php. Between these two languages you can add almost all the action and processing you need to a web page.