130 likes | 244 Views
Introduction to JavaScript. CINS/WEBT 143 Jim Doran. Understanding Client/Server Architecture. Web built on a two-tier client/server system Requests and responses through which a Web browser and Web server communicate happen with HTTP. Web Standards. Behavior. JavaScript.
E N D
Introduction to JavaScript CINS/WEBT 143 Jim Doran
Understanding Client/Server Architecture Web built on a two-tier client/server system • Requests and responses through which a Web browser and Web server communicate happen with HTTP
Web Standards Behavior
JavaScript JavaScript is an implementation of the ECMAScript language standard and is typically used to enable programmatic access to computational objects within a host environment.
JavaScript • JavaScript (brief) history • Developed by Brendan Eich as Mocha • First introduced in Navigator (LiveScript) • Navigator 2.0: name changed to JavaScript 1.0 • Microsoft released Internet Explorer 4.0 version of JavaScript (Jscript) • ECMAScript • International, standardized version of JavaScript • Most recent version: edition 3
JavaScript and Client-Side Scripting • When HTML was first developed, Web pages were static • Static Web pages cannot change after the browser renders them • HTML and XHTML could only be used to produce static documents • JavaScript • Client-side scripting language that allows Web page authors to develop interactive Web pages and sites
JavaScript Advantages • Adds dynamic behavior to Web pages • Used to “remember” state • Access to browser information, form elements, images • Can be used to amend browser shortcomings Disadvantages • No mechanism for creating a network connection or accessing a database • Cannot be used outside the Web browser (sort of) • Same domain policy (for now)
Client-side Scripting • Executes in the browser on the user’s computer after the page elements are downloaded • Reduces processing load on the Web server, taking advantage of the client machine • Speeds up user experience
Server-side Scripting • Executes on the Web server before the page is presented to the visitor • Can handle file manipulation, document creation and modification • Database connectivity • More secure, more powerful (heavy lifting) • PHP, ASP, ColdFusion, Java, CGI, etc.
JavaScript <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The Hello World Page</title> <script type="text/javascript"> alert("Hello, World!"); </script> </head> <body> </body> </html>
JavaScript • JavaScript is case sensitive • Avoid putting code in the <body></body> if possible (separation of content, formatting and behavior) • Use JavaScript to progressively enhance your documents (lots on this later) • Let’s take a look…