47javascript

47javascript - CS1315 Introduction to Media Computation Web...

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

View Full Document Right Arrow Icon
CS1315: Introduction to Media Computation Web Pages that Interact
Background image of page 1

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

View Full DocumentRight Arrow Icon
Contents Javascript Using Javascript to make page contents vary A taste of a new programming language Using Javascript to respond to the user How OSCAR and Ebay work
Background image of page 2
What do other languages look like? We call the language “grammar” its syntax Python is a fairly traditional language in terms of syntax. Languages like Scheme, Lisp and Squeak are significantly different. Some points of difference: Whether or not variables have to be declared before first use. Details of how individual lines are written. Details of how blocks are defined.
Background image of page 3

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

View Full DocumentRight Arrow Icon
JavaScript JavaScript is meant to be a scripting language, like Python. Scripting languages are good at solving simple tasks. It’s designed to look like Java to ease the transition in either way. JavaScript can be used by the web server (used on the computer accessed via the Internet), or it can be used within an HTML page. If it’s within the HTML page, it’s actually executed by the user’s browser & computer . We call that client side JavaScript.
Background image of page 4
Preview: Inserting Javascript into HTML <p>This is a very simple web page.</p> <p><image src = "mediasources/barbara.jp g" /> </p> <p>This is being served to you on <script> document.write(Date()); </script> </p>
Background image of page 5

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

View Full DocumentRight Arrow Icon
JavaScript syntax: Variables Variables must be declared before use. You can’t just say: a = 12 You can either say: var a = 12; Or: var a; a = 12 In other languages (like Java), you might also declare the variable’s type int a = 12;
Background image of page 6
JavaScript syntax: Blocks Blocks are delimited with curly braces. function test() { document.writeln("This is a test") ; } like def begins a block ends a block
Background image of page 7

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

View Full DocumentRight Arrow Icon
JavaScript syntax: Individual statements Lots of differences: function instead of def End lines with semicolons “ ; (and statements can have line breaks in the middle of them.) The for statement is numeric (mostly) and has different parts to it. You use write or writeln instead of print But they’re mostly detailed changes. The basic operation of JavaScript is similar to Python.
Background image of page 8
JavaScript is all about objects Just about every “function” is really a method. For example, there is no global print . There is a function
Background image of page 9

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

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

This note was uploaded on 01/26/2012 for the course CS 1315 taught by Professor Sweat during the Fall '08 term at Georgia Tech.

Page1 / 33

47javascript - CS1315 Introduction to Media Computation Web...

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

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