18 function calculation II

18 function calculation II - Example 3 A simple JavaScript...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Example 3 - A simple JavaScript program: Name: John Which color? Purple When the page is loaded, the user types a name and a text color. Then the page content is setup accordingly. Event Input Processing and output
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
<html> <head> <title>Demo</title> </head> <body>      <script type="text/javascript">           … prompt('Who?', '');      … prompt('Which color?', '');      … document.write(…);      </script> ..         .. </body> </html> Explanation: The input dialogs are invoked by prompt(. .) . document.write(. .) outputs the content in the page. Each JavaScript statement is ended with a semi-colon: ; . Let’s glance at the code (Example 3): Name: John Which color? Purple For simplicity, from now on we omit the <!DOCTYPE> tag and the xmlns attribue in the <html> tag in our course materials.
Background image of page 2
What is JavaScript A language that allows you to write programs that are e xecuted by a web-browser.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/10/2012 for the course CS 1301 taught by Professor Dr.wong during the Winter '08 term at City University of Hong Kong.

Page1 / 5

18 function calculation II - Example 3 A simple JavaScript...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online