Javascript - USF Computer Science



Javascript

The BROWSER scripting language.

Similar syntax to java.

History: Netscape created to allow dynamic web pages.

Uses: Many, here are a couple:

verifying and reacting to user input,

updating page without making user wait

Javascript tutorial:

Alert box sample:

function disp_confirm()

{

var r=confirm("Press a button");

if (r==true)

{

document.write("You pressed OK!");

}

else

{

document.write("You pressed Cancel!");

}

}

Can also put javascript in a file external to the html:

confirm.js:

function disp_confirm()

{

var r=confirm("Press a button");

if (r==true)

{

document.write("You pressed OK!");

}

else

{

document.write("You pressed Cancel!");

}

}

See sample at

Advanced Uses

DOM – Document Object Model

Your program can get at the elements in the html.

So, for instance, you can sort a list in different ways.

A big data structure representing the html page.

AJAX – Asynchronous javascript and xml

Call a server to get data, asynchronously.

User doesn’t have to wait for call to web service to complete

Vacation fun: Write mastermind with html and javascript!

-----------------------

Html page

Java script

External Web service

Server

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download