• Like
Javascript.doc
Upcoming SlideShare
Loading in...5
×
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
282
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 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!"); }
  • 2. 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:
  • 3. 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
  • 4. 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!