Javascript.doc
Upcoming SlideShare
Loading in...5
×
 

Javascript.doc

on

  • 512 views

 

Statistics

Views

Total Views
512
Views on SlideShare
512
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Javascript.doc Javascript.doc Document Transcript

  • CS 110 Fall 2007 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: http://www.w3schools.com/js/js_intro.asp Alert box sample: http://www.w3schools.com/js/tryit.asp? filename=tryjs_confirm <html> <head> <script type="text/javascript"> function disp_confirm() { var r=confirm("Press a button"); if (r==true) { document.write("You pressed OK!"); }
  • CS 110 Fall 2007 else { document.write("You pressed Cancel!"); } } </script> </head> <body> <input type="button" onclick="disp_confirm()" value="Display a confirm box" /> </body> </html> Can also put javascript in a file external to the html: <html> <head> <script src="confirm.js"> </script> </head> <body> <input type="button" onclick="disp_confirm()" value="Display a confirm box" /> </body> </html> confirm.js:
  • CS 110 Fall 2007 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 http://www.cs.usfca.edu/~wolber/jsSamples/confirm2.html Advanced Uses DOM – Document Object Model
  • CS 110 Fall 2007 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. Html page Java script External Web service Server User doesn’t have to wait for call to web service to complete Vacation fun: Write mastermind with html and javascript!