Introducing JavaScript.ppt_第1頁
Introducing JavaScript.ppt_第2頁
Introducing JavaScript.ppt_第3頁
Introducing JavaScript.ppt_第4頁
Introducing JavaScript.ppt_第5頁
已閱讀5頁,還剩20頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Introducing JavaScript,Goals,By the end of this lecture you should Understand the purpose of JavaScript. Understand the basic rules governing JavaScript syntax. Understand how we can link our JavaScript applications to web pages.,Goals (continued),Understand how events are central to JavaScript prog

2、ramming. Understand how we can use built-in event handlers to detect events and program to those events.,What is JavaScript?,JavaScript is a client-side language. JavaScript code executes within the confines of a web page. JavaScript syntax is similar to C and Java (but, JavaScript is NOT Java!). Ja

3、vaScript deals with objects.,Review: What is an Object?,An object is a unique programming entity that has attributes to describe it (like adjectives in grammar) and methods to retrieve/set attribute values (like verbs in grammar).,Common JavaScript Objects,A web browsers window A string of character

4、s An integer number Text in a web page A menu in a web page An image A path to an image saved in memory,JavaScript Syntax,Spaces do not matter to the JavaScript interpreter. Executable lines of JavaScript code end with a semi-colon:window.alert(Hi There!);,JavaScript Syntax,Programming structures be

5、gin and end with a curly brace:if(strUserName = JOE) /Executable lines /go here/End If,A Note on Spacing & Indention,Use lots of white space to clarify your programming structures. Use indention to differentiate between a structures header and its body (executable block).,JavaScript Comments,Single

6、line comments begin with 2 forward slashes:/This is a comment./These lines are also/single line/comments.,JavaScript Comments,You can also create comments to span multiple lines by beginning with /* and ending with */: /* This is a comment * that spans multiple * lines. */,Linking JavaScript to HTML

7、,We can develop a JavaScript application directly inside a web page using a container. We can also develop our application in an external document and then link it by using the src attribute.,More on the Tag,Normally, we nest inside the container. The tag has several attributes that give the browser

8、 important information about your application. Two important attributes are type and language.,The type Attribute,The type attribute defines the MIME type for your program. Well always use the MIME value of text/javascript: ,The language Attribute,The language attribute defines the version of JavaSc

9、ript in which you code. Well always use the MIME value of JavaScript 2.1: ,Take the next few minutes to examine the file called introToJavaScript_01.html.,The src Attribute,We can link external JavaScript applications using the src attribute: ,Take the next few minutes to examine the file called int

10、roToJavaScript_02.html.,Detecting a Web Page Event,We write our scripts so they execute by reacting to events within a web browser. Since events are at the heart of JavaScript programming, we need a way to detect events. We do that by using built-in event handlers ,JavaScript Event Handlers,onAbort

11、onBlur onChange onClick onError onFocus,onLoad onMouseOut onMouseOver onSelect onSubmit onUnload,Reference: JavaScript Event Handlers,Take the next few minutes to examine the file called introToJavaScript_03.html.,The main Module (Function),Most programs have a central point through which all operat

12、ions process. Traditionally, programmers name this module (function) main. We can tell main to execute when a page loads by using the onLoad event handler ,The onLoad Event Handler,The onLoad event handler detects a special event that of a web page loading in a web browser. We use onLoad to connect our JavaScript applications as an attribute of the tag.,Take the next few minutes to re-visit the file introToJavaScript_01.html.See if you can find the event handler ,Summary,JavaScript is a client-side l

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論