ࡱ > B D A ` 5 jbjb $" |c |c 6 r r r r t 8 , t P" ( ( P P P P U U U ! ! ! ! ! ! ! , J# R % Z ! U U U U ! ! r r P P k " ! ! ! U r l P P ! ! 4 R " r r r r U ! ! ! , ! Xv a f ! ! " 0 P" ! % ! % ! ! t t t t 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: HYPERLINK "http://www.w3schools.com/js/js_intro.asp" http://www.w3schools.com/js/js_intro.asp Alert box sample: http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm
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 HYPERLINK "http://www.cs.usfca.edu/~wolber/jsSamples/confirm2.html" http://www.cs.usfca.edu/~wolber/jsSamples/confirm2.html 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 doesnt have to wait for call to web service to complete Vacation fun: Write mastermind with html and javascript! CS 110 Fall 2007 Html page Java script External Web service Server ; < = e f g z Ŭ֝Ō{jYH5H $h h 5B*CJ OJ QJ ph !h } h B*CJ OJ QJ ph !h,KL h B*CJ OJ QJ ph !hO h B*CJ OJ QJ ph !h9 h B*CJ OJ QJ ph !hv/) h B*CJ OJ QJ ph h h 0J CJ OJ QJ 0j h h B*CJ OJ QJ Uph !h h B*CJ OJ QJ ph *j h h B*CJ OJ QJ Uph h h CJ OJ QJ h h , - E F | ~ g h ! . 2 W ^gd `gd $a$gd 4 W [ ` d D E L S m w `gd gd ^gd E S w 1 2 3 R c d e g h i j k l {]]]@ 8j h B*CJ OJ QJ UaJ mH nH ph sH tH ;j h 5B*CJ OJ QJ UaJ mH nH ph sH tH hs$ h 0J CJ OJ QJ 0j hs$ h B*CJ OJ QJ Uph !h4^F h B*CJ OJ QJ ph *j h4^F h B*CJ OJ QJ Uph $h h 5B*CJ OJ QJ ph !h } h B*CJ OJ QJ ph !h1 h B*CJ OJ QJ ph 0 = A g k p t 3 4 5 6 7 8 9 : ; < = K L ^gd gd L h i 5 6 b c e h j k m n o p gd l 5 h !h1 h B*CJ OJ QJ ph * + 2 3 4 5 gd " :p / =!"#$% D y K ) h t t p : / / w w w . w 3 s c h o o l s . c o m / j s / j s _ i n t r o . a s p y KR h t t p : / / w w w . w 3 s c h o o l s . c o m / j s / j s _ i n t r o . a s p U D y K 8 h t t p : / / w w w . c s . u s f c a . e d u / ~ w o l b e r / j s S a m p l e s / c o n f i r m 2 . h t m l y Kp h t t p : / / w w w . c s . u s f c a . e d u / ~ w o l b e r / j s S a m p l e s / c o n f i r m 2 . h t m l <