学习JavaScript(第二版,影印版)
学习JavaScript(第二版,影印版)
Shelley Powers
出版时间:2009年07月
页数:375
如果你想使用JavaScript来利用当今强大的浏览器,《学习JavaScript》为这个Web开发中奇妙且不可缺少的语言提供了完整而实际的指导。你将会学习从原始数据类型到复杂特性的所有内容,包括与Ajax和动态页面效果有关的JavaScript元素。学完这本书,你将能够使用最复杂的程序库和Web应用程序。
第二版中包括了许多JavaScript运用中的最佳实践和范例,展示了如何将语言和浏览器环境整合,以及如何为符合标准的Web站点实践准确的编码技术。
有了这本书,你将能够:
· 学习JavaScript应用程序结构,包括基本语句和控制结构
· 识别JavaScript对象:String、Number、Boolean、Function等
· 使用浏览器调试工具和故障检测技术
· 理解事件处理、表单事件和带有表单的JavaScript应用程序
· 使用浏览器对象模型(BOM)、文档对象模型(DOM)和自定义对象进行开发
· 学习关于浏览器cookies和更多最新的客户端存储技术
· 利用Ajax应用程序得到使用XML和JSON的详细信息
《学习JavaScript》遵循已被证实的学习原理,帮助你以简单的步骤吸收这些原理,以使你理解如何在各种浏览器中建立强大且反应迅速的应用程序。
“无论你是一个初学者,还是一个正在寻求一种新语言的有经验的程序设计者,我都要明确地向你推荐《学习JavaScript》这本书。作者Shelley简单明了的分析,可以帮助你掌握这种语言的基础及细微之处,从而将它最适当地用于你自己的Web站点。”
——Anthony T. Holdener III, O'Reilly出版的《Ajax权威指南》一书的作者
Shelley Powers从事并编写Web技术超过13年。近年来她在O'Reilly出版的图书内容涵盖了语义网(semantic web)、Ajax、JavaScript及web graphics。同时,她也是一名狂热的业余摄影爱好者和Web开发爱好者。
  1. Preface
  2. 1. Hello JavaScript!
  3. Hello World!
  4. Hello World! Once Again
  5. The script Tag
  6. JavaScript Versus ECMAScript Versus JScript
  7. Defining Functions in JavaScript
  8. Event Handlers
  9. The document Browser Object
  10. The property Operator
  11. The var Keyword and Scope
  12. Statements
  13. Comments
  14. What You Didn’t See: HTML Comments and CDATA Sections
  15. JavaScript Files
  16. Accessibility and JavaScript Best Practices
  17. Accessibility Guidelines
  18. noscript
  19. 2. JavaScript Data Types and Variables
  20. Identifying Variables
  21. Naming Guidelines
  22. Primitive Types
  23. The String Data Type
  24. String Escape Sequences
  25. String Encoding
  26. Converting to Strings
  27. The Boolean Data Type
  28. The Number Data Type
  29. The null and undefined Variables
  30. Constants: Named but Not Variables
  31. Test Your Knowledge: Quiz
  32. Test Your Knowledge: Answers
  33. 3. Operators and Statements
  34. The Format of a JavaScript Statement
  35. The Assignment Statement
  36. The Arithmetic Operators
  37. The Unary Operators
  38. Operator Precedence
  39. A Handy Shortcut: Assignment with Operation
  40. The Bitwise Operators
  41. Conditional Statements and Program Flow
  42. The if…else Conditional Statement
  43. The switch Conditional Statement
  44. The Conditional Operators
  45. The Equality and Identity (String Equality) Operators
  46. Other Relational Operators
  47. The One and Only JavaScript Ternary Operator
  48. The Logical Operators
  49. Advanced Statements: The Loops
  50. The while Loop
  51. The do…while Loop
  52. The for Loops
  53. Test Your Knowledge: Quiz
  54. Test Your Knowledge: Answers
  55. 4. The JavaScript Objects
  56. Primitive Data Types As Objects
  57. Boolean, Number, and String
  58. The Boolean Object
  59. The Number Object, Static Properties, and Instance Methods
  60. The String Object
  61. Regular Expressions and RegExp
  62. The RegExp Methods: test and exec
  63. Working with Regular Expressions
  64. The Date Object
  65. The Math Object
  66. The Math Properties
  67. The Math Methods
  68. JavaScript Arrays
  69. FIFO Queues
  70. Test Your Knowledge: Quiz
  71. Test Your Knowledge: Answers
  72. 5. Functions
  73. Declarative Functions
  74. Function Naming Conventions and Size
  75. Function Returns and Arguments
  76. Anonymous Functions
  77. Function Literals
  78. Functions and Recursion
  79. Nested Functions, Function Closure, and Memory Leaks
  80. Callback Functions
  81. Function Type Summary
  82. Function Scope
  83. Function As Object
  84. Test Your Knowledge: Quiz
  85. Test Your Knowledge: Answers
  86. 6. Troubleshooting, Debugging, and Cross-Browser Issues
  87. Simple Ways to Debug
  88. Development and Debugging Tools by Browser
  89. Firefox and Firebug
  90. Using console.log
  91. Firefox, the Web Developer Toolkit, and NoScript
  92. Opera and Dragonfly
  93. Safari/WebKit and the Web Inspector
  94. Internet Explorer
  95. Dealing with Cross-Browser Differences
  96. Object Detection
  97. Where Object Detection Fails
  98. DOCTYPE, X-UA-Compatible, and Quirks Mode
  99. Breaking Backward Compatibility: The IE8 http-equiv Meta Tag
  100. Test Your Knowledge: Quiz
  101. Test Your Knowledge: Answers
  102. 7. Catching Events
  103. The Events
  104. Level 0 Event Handling
  105. The Event Object
  106. Event Bubbling
  107. Event Handlers and this
  108. The DOM Level 2 Event Model
  109. Generating Events
  110. Test Your Knowledge: Quiz
  111. Test Your Knowledge: Answers
  112. 8. Forms, Form Events, and Validation
  113. Attaching Events to Forms: Different Approaches
  114. Cross-Browser Event Handling
  115. Canceling an Event
  116. Selection
  117. Dynamically Modifying the Selection
  118. Selection and Auto-Selection
  119. Radio Buttons and Checkboxes
  120. The text, textarea, password, and hidden Input Elements
  121. Text Validation
  122. Input Fields and Regular Expression Validation
  123. Forms, the Sandbox, and XSS
  124. Test Your Knowledge: Quiz
  125. Test Your Knowledge: Answers
  126. 9. Browser As Puzzle Box
  127. The Structure of the Browser at a Glance
  128. The window Object
  129. Creating and Controlling Windows
  130. The Dialogs: alert, confirm, and prompt
  131. Creating Custom Windows
  132. Modifying a Window
  133. Frames
  134. The location Object
  135. Remote Scripting with the iframe
  136. Adding and Controlling Timers
  137. The history, screen, and navigator Objects
  138. The history Object
  139. The screen Object
  140. The navigator Object
  141. The history, screen, and navigator Properties in Action
  142. The Document Object
  143. Links
  144. Images
  145. innerHTML
  146. Test Your Knowledge: Quiz
  147. Test Your Knowledge: Answers
  148. 10. Cookies and Other Client-Side Storage Techniques
  149. The JavaScript Sandbox and Cookie Security
  150. The Same-Origin Security Policy
  151. Using document.domain
  152. All About Cookies
  153. Storing and Reading Cookies
  154. Flash Shared Objects, Google Gears, and HTML5 DOM Storage
  155. Test Your Knowledge: Quiz
  156. Test Your Knowledge: Answers
  157. 11. The DOM, or Web Page As Tree
  158. A Tale of Two Interfaces
  159. The DOM HTML API
  160. The DOM HTML Objects and Their Properties
  161. DOM (HTML) Collections
  162. Understanding the DOM: The Core API
  163. The DOM Tree
  164. Node Properties and Methods
  165. The DOM Core Document Object
  166. Element and Access in Context
  167. Modifying the Tree
  168. Test Your Knowledge: Quiz
  169. Test Your Knowledge: Answers
  170. 12. Dynamic Pages
  171. JavaScript, CSS, and the DOM
  172. The Style Property/Attributes
  173. Fonts and Text
  174. Font Style Properties
  175. Text Properties
  176. Position and Movement
  177. Dynamic Positioning
  178. Drag-and-Drop
  179. Size and Clipping
  180. Overflow and Dynamic Content
  181. The Clipping Rectangle
  182. Display, Visibility, and Opacity
  183. The Right Tool for the Right Effect
  184. Just-in-Time Information
  185. Revisiting the DOM: Collapsing Forms, Query Selectors, and Class Names
  186. Test Your Knowledge: Quiz
  187. Test Your Knowledge: Answers
  188. 13. Creating Custom JavaScript Objects
  189. The JavaScript Object and Prototyping
  190. Prototyping
  191. Creating Your Own Custom JavaScript Objects
  192. Enter the Function
  193. Public and Private Properties and Where this Enters the Picture
  194. Getters and Setters
  195. Object Encapsulation
  196. Chaining Constructors and JavaScript Inheritance
  197. One-Off Objects
  198. Object Libraries: Packaging Your Objects for Reuse
  199. Advanced Error Handling Techniques (try, throw, catch)
  200. Test Your Knowledge: Quiz
  201. Test Your Knowledge: Answers
  202. 14. Moving Outside the Page with Ajax
  203. How Ajax Works
  204. Hello Ajax World!
  205. The XMLHttpRequest Object and Preparing to Send the Request
  206. Object, Object, Who Has the Object?
  207. The XMLHttpRequest Methods
  208. Processing the Web Request Return
  209. Checking the readyState and status of an Ajax Request
  210. Processing the Web Request Result
  211. Ajax: It’s Not Only Code
  212. The Dynamic Nature of Ajax
  213. Ajax Accessibility and Degrading Gracefully
  214. Security and Workarounds
  215. JavaScript and Ajax Libraries
  216. Test Your Knowledge: Quiz
  217. Test Your Knowledge: Answers
  218. 15. Ajax Data: XML or JSON?
  219. XML-Formatted Ajax Results
  220. The Data’s MIME Type
  221. Generating the XML on the Server
  222. Processing the XML on the Client
  223. JavaScript Object Notation
  224. A Simple JSON Application
  225. The JSON Object
  226. Test Your Knowledge: Quiz
  227. Test Your Knowledge: Answers
  228. Index
书名:学习JavaScript(第二版,影印版)
作者:Shelley Powers
国内出版社:东南大学出版社
出版时间:2009年07月
页数:375
书号:978-7-5641-1649-1
原版书出版商:O'Reilly Media
Shelley Powers
 
Shelley Powers从JavaScript初次开发到现在最新的图形和设计工具发布,Shelley Powers已经从事Web技术工作和写作达15年之久。她最近在O’Reilly出版的图书包括语义网、Ajax、JavaScript和Web图形。她是一位热情的业余摄影师,也是Web开发的狂热爱好者,她从JavaScript刚发布时,就开始使用和编写Web技术相关书籍。她之前在O’Reilly出版了8本书,包括Developing ASP Components(2001),Adding Ajax(2007)和JavaScript Cookbook(2010)。
 
 
The animal on the cover of Learning JavaScript, Second Edition, is a baby black, or
hook-lipped, rhinoceros (Diceros bicornis). The black rhino is one of two African species
of rhinos. Weighing up to one and a half tons, it is smaller than its counterpart—
the white, or square-lipped, rhinoceros. Black rhinos live in savanna grasslands, open
woodlands, and mountain forests in a few small areas of southwestern, south central,
and eastern Africa. They prefer to live alone and will aggressively defend their territory.
With an upper lip that tapers to a hooklike point, the black rhino is perfectly suited to
pluck leaves, twigs, and buds from trees and bushes. It is able to eat coarser vegetation
than other herbivores.
Black rhinos are odd-toed ungulates, meaning they have three toes on each foot. They
have thick, gray, hairless hides. Among the most distinctive of the rhino’s features is
its two horns, which are actually made of thickly matted hair rather than bone. The
rhino uses its horns to defend itself against lions, tigers, and hyenas, or to claim a female
mate. The courtship ritual is often violent, and the horns can inflict severe wounds.
After mating, the female and male rhinos have no further contact. The gestation period
is 14 to 18 months, and the calves nurse for a year, though they are able to eat vegetation
almost immediately after birth. The bond between a mother and her calf can last up to
four years before the calf leaves its home.
In recent years, rhinos have been hunted to the point of near extinction. Scientists
estimate that there may have been as many as a million black rhinos in Africa 100 years
ago, a number that has dwindled to 2,400 today. All five remaining species, which
include the Indian, Javan, and Sumatran rhinos, are now endangered. Humans are
considered their biggest predators.