版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 妊娠期卒中患者個體化治療方案的調整策略-1
- 固鎮(zhèn)綜合考試題目及答案
- 材料專業(yè)導論試題及答案
- 2026寶坻事業(yè)編考試題及答案
- 頭頸癌免疫治療后的靶向維持-1
- 大數(shù)據(jù)驅動的醫(yī)療廢物風險分級管控策略-1
- 招工考試常識題及答案
- ps考試試卷及答案
- 2025年大學建筑工程施工(建筑施工組織)試題及答案
- 2025年大學衛(wèi)生信息管理(衛(wèi)生信息系統(tǒng))試題及答案
- JJF 2266-2025血液融漿機校準規(guī)范
- 公司兩權分離管理制度
- 紫砂陶制品行業(yè)深度研究分析報告(2024-2030版)
- 餐飲公司監(jiān)控管理制度
- 種雞免疫工作總結
- 河南省商丘市柘城縣2024-2025學年八年級上學期期末數(shù)學試題(含答案)
- 教育機構財務管理制度及報銷流程指南
- 給女朋友申請書
- 2023-2024學年北京市海淀區(qū)八年級上學期期末考試物理試卷含詳解
- 2024版房屋市政工程生產安全重大事故隱患判定標準內容解讀
- GB 21258-2024燃煤發(fā)電機組單位產品能源消耗限額
評論
0/150
提交評論