The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks (Paperback)
暫譯: JavaScript 精華:101 個必備技巧、竅門與破解(平裝本)
Cameron Adams, James Edwards
- 出版商: Sitepoint
- 出版日期: 2006-03-28
- 售價: $1,570
- 貴賓價: 9.5 折 $1,492
- 語言: 英文
- 頁數: 592
- 裝訂: Paperback
- ISBN: 0975240269
- ISBN-13: 9780975240267
-
相關分類:
JavaScript
海外代購書籍(需單獨結帳)
買這商品的人也買了...
-
$750$638 -
$460$363 -
$780$663 -
$650$507 -
$580$493 -
$450$383 -
$300$240 -
$800$680 -
$480$374 -
$600$474 -
$580$493 -
$520$343 -
$743Microsoft Windows Workflow Foundation Step by Step (Paperback)
-
$880$695 -
$780$616 -
$290$226 -
$600$480 -
$360$306 -
$880$695 -
$650$553 -
$450$356 -
$690$545 -
$450$383 -
$680$537 -
$580$493
相關主題
商品描述
Description
“Take control with the ultimate JavaScript toolkit”
Among the 101 Tips, Tricks & Hacks you'll learn how-to:
- Create a slick yet accessible drop-down menu system
- Take control of your web pages with the DOM
- Validate forms in real time using regular expressions
- Optimize your code so that it runs faster
- Manage style sheets and modify styles on-the-fly
- Produce sophisticated drag-and-drop interaction
- Enhance your site with slick, animated transitions
- Create AJAX applications with the XMLHttpRequest object
…and much more. Far too many things to mention here!
- Preface
- Who Should Read this Book?
- What’s in this Book?
- The Book’s Web Site
- The Code Archive
- Updates and Errata
- The SitePoint Forums
- The SitePoint Newsletters
- Your Feedback
- Acknowledgements
- Getting Started with JavaScript
- JavaScript Defined
- JavaScript’s Limitations
- Security Restrictions
- JavaScript Best Practices
- Providing for Users who Don’t Have JavaScript (Progressive Enhancement)
- Separating Content from Behavior (Unobtrusive Scripting)
- Using Braces and Semicolons (Consistent Coding Practice)
- Adding a Script to a Page
- Putting HTML Comments Around Code
- The language Attribute
- Getting Multiple Scripts to Work on the Same Page
- Hiding JavaScript Source Code
- Debugging a Script
- Understanding a Browser’s Built-in Error Reporting
- Using alert
- Using try-catch
- Writing to the Page or Window
- Using an External Debugger
- Strict Warnings
- Summary
- Working with Numbers
- Doing Math with JavaScript
- Rounding a Number to x Decimal Places
- Creating and Constraining Random Numbers
- Converting a Number to a String
- Formatting Currency Values
- Converting a String to a Number
- Converting Numbers to Ordinals (-st, -nd, -rd, -th)
- Summary
- Working with Strings
- Including a Special Character in a String
- Transforming the Character Case of a String
- Encoding a URL
- Comparing Two Strings
- Finding a Substring within a String
- Splitting a String into Substrings
- Creating a Regular Expression
- Testing whether a String Matches a Regular Expression
- Testing whether a String Contains Only Numeric Data
- Testing whether a String is a Valid Phone Number
- Testing whether a String is a Valid Email Address
- Searching and Replacing Text using a Regular Expression
- Summary
- Working with Arrays
- Using Array-literals
- Creating an Array of Arrays
- Indexing an Array with Strings Instead of Numbers
- Turning an Array into a String
- Adding or Removing Members from an Array
- Sorting an Array into Alphabetical or Numeric Order
- Sorting a Multi-dimensional Array
- Sorting an Array Randomly
- Summary
- Navigating the Document Object Model
- Accessing Elements
- Creating Elements and Text Nodes
- Changing the Type of an Element
- Removing an Element or Text Node
- Reading and Writing the Attributes of an Element
- Getting all Elements with a Particular Attribute Value
- Adding and Removing Multiple Classes to/from an Element
- Summary
- Processing and Validating Forms
- Reading and Writing the Data in a Text Field
- Reading and Setting the State of a Checkbox
- Reading and Setting the State of a Radio Button
- Reading and Setting the Value of a Select Box
- Validating a Mandatory Text Field
- Validating a Numeric Field
- Validating an Email Address Field
- Checking for Unselected Radio Buttons
- Stopping a Form Being Submitted Unless all its Fields are Valid
- Validating a Form with an Unknown Number of Fields
- Printing Inline Error Messages when Validating a Form
- Making Form Fields Appear or Disappear, Based on the Value of other Fields
- Summary
- Working with Windows and Frames
- Using Popup Windows
- What’s Wrong with Popups?
- How Do I Minimize the Problems?
- Opening Off-site Links in a New Window
- Communicating Between Frames
- Getting the Scrolling Position
- Making the Page Scroll to a Particular Position
- Getting the Viewport Size (the Available Space inside the Window)
- Summary
- Working with Cookies
- Writing Cookies
- Reading a Cookie
- Setting a Cookie to Expire at a Specific Date and Time
- Making a Cookie Accessible Only from a Specific Domain or Path
- Circumventing Browser Restrictions on the Number of Cookies you can Use
- Summary
- Working with Dates and Times
- Getting the Date and Time
- Formatting a Date into a Sentence
- Formatting the Time into a 12- or 24-hour Clock
- Comparing Two Dates
- Formatting the Difference Between Dates
- Summary
- Working with Images
- Preloading Images
- Swapping One Image for Another
- Displaying an Image at Random
- Making a Slideshow of Several Images
- Making an Image Fade in or out
- Making an Image-based Clock that Updates in Real Time
- Making a Progress Indicator
- Summary
- Detecting Browser Differences
- Identifying Support for a Particular Feature
- Identifying a Particular Browser
- Detecting Quirks Mode and Standards Mode
- Summary
- Using JavaScript with CSS
- Changing the Style of a Single Element
- Changing the Style of a Group of Elements
- Retrieving the Computed Style of an Element
- Making a Style Sheet Switcher
- Maintaining Alternate Style Sheet States
- Making a Style Sheet Switcher that Handles Multiple Media Types
- Reading and Modifying an Existing Style Sheet
- Adding New Style Sheet Rules
- Deleting a Rule from a Style Sheet
- Creating a New Style Sheet
- Summary
- Basic Dynamic HTML
- Handling Events
- The Short Way: Using Event Handlers
- The W3C Way (Event Listeners)
- Referencing the Target Element
- What is Event Bubbling, and How do I Control it?
- Finding the Size of an Element
- Finding the Position of an Element
- Detecting the Position of the Mouse Cursor
- Displaying a Tooltip when you Mouse Over an Element
- Sorting Tables by Column
- Summary
- Time and Motion
- Using setTimeout and setInterval
- Making an Object Move Along a Set Path
- Making Animation Less Jerky
- Animation Frame Times
- Changing Between Frames
- Complexity of the Animation
- The Speed of the Computer
- The Speed of the Browser
- Implementing Drag-and-drop Behavior
- Reordering a List Using Drag-and-drop Functionality
- Making a Scrolling News Ticker
- Creating Clip-based Transition Effects
- Making a Slider Control
- Summary
- DHTML Menus and Navigation
- Making a Drop-down or Fly-out Menu
- Adding Arrows to Indicate the Presence of a Submenu
- Adding Timers so the Menus Don’t Open and Close so Abruptly
- Making Sure the Menus Stay Inside the Window
- Making the Menus Display Over select Elements
- Making a Folder Tree or Expanding Menu
- Discussion
- Indicating Expanded Branches in a Menu
- Allowing Only One Menu Branch to Be Open at Any Time
- Opening the Current Sub-branch Automatically
- Summary
- JavaScript and Accessibility
- Is JavaScript Inaccessible?
- What is Accessibility?
- Who are the Affected Users?
- Making Scripts Accessible to the Keyboard
- Using Device-independent Event Handlers
- Making Scripts Accessible to the Keyboard as well as the Mouse
- Rollovers and Revealing Content
- Form Validation
- Drag-and-drop Functionality
- AJAX and other Remote Scripting Techniques
- Making title Attribute Tooltips Display on Focus
- Making a DHTML Menu Accessible to the Keyboard
- Making a DHTML Menu Usable via the Keyboard
- Making a DHTML Slider Control Accessible to the Keyboard
- Making Scripts Accessible to Screen Readers
- JavaScript Behaviors
- Rollovers and Revealing Content
- Form Validation
- Non-user-initiated Scripts
- AJAX and other Remote Scripting Techniques
- Tricks and Hacks
- Towards Best Practice
- The Mission
- The Joy of Mode
- Reaching toward a Best Practice Approach
- Into the Future
- Summary
- Using JavaScript with Flash
- Detecting whether Flash is Installed in a Browser
- Communicating Between JavaScript and Flash
- FSCommand
- Flash/JavaScript Integration Kit
- Summary
- Building Web Applications with JavaScript
- Retrieving Data Using XMLHttpRequest
- Requesting Data from a Server
- Parsing the Data
- Caching
- AJAX Frameworks
- Retrieving Data without Using XMLHttpRequest
- Creating Custom Dialogs (Such as Popup Forms)
- Creating Editable Elements
- Controlling Text Selections
- Creating an Auto-complete Text Field
- Summary
- Object Orientation in JavaScript
- What’s so Good about Object Orientation?
- Abstraction
- Encapsulation
- Class Inheritance
- Polymorphism
- Object Based Code vs Object Oriented Code
- Writing an Object Oriented Script
- Creating Methods for an Object
- Prototype-based Method Creation
- Modelling Inheritance
- Understanding Scope
- Implementing Namespaces
- Summary
- Keeping up the Pace
- Making Scripts Run Faster
- Saving References to Objects you Use Frequently
- Using Ternary Operators and Switch Statements
- Optimizing Loops
- Avoiding eval
- Avoiding Strict Warnings
- Optimizing for a Particular Browser
- Writing Scripts Using Less Code
- Dividing Tasks into Functions (or Using OO)
- Using Arrays and Iteration to Avoid Code Repetition
- Compacting Conditions and Return Statements
- Optimizing Scripts for the Web
- Removing Comments and Unnecessary Whitespace
- Compacting the Names of Variables and Properties
- Avoiding Memory Leaks
- Avoiding Circular References
- Cleaning Up After the Fact
- Making Scripts Run Before the Load Event
- Summary
- Index
商品描述(中文翻譯)
**描述**
“掌控終極 JavaScript 工具包”
在這本書中,您將學到 101 個技巧、竅門和黑客技術,包括:
- 創建一個流暢且可訪問的下拉菜單系統
- 使用 DOM 控制您的網頁
- 使用正則表達式實時驗證表單
- 優化您的代碼以提高運行速度
- 管理樣式表並即時修改樣式
- 生成複雜的拖放互動
- 使用流暢的動畫過渡增強您的網站
- 使用 XMLHttpRequest 對象創建 AJAX 應用程序
……還有更多,這裡無法一一列舉!
**目錄**
- 前言
- 誰應該閱讀這本書?
- 這本書的內容是什麼?
- 本書的網站
- 代碼檔案
- 更新和勘誤
- SitePoint 論壇
- SitePoint 通訊
- 您的反饋
- 感謝詞
- 開始使用 JavaScript
- JavaScript 定義
- JavaScript 的限制
- 安全限制
- JavaScript 最佳實踐
- 為沒有 JavaScript 的用戶提供支持(漸進增強)
- 將內容與行為分離(不干擾腳本)
- 使用大括號和分號(一致的編碼實踐)
- 向頁面添加腳本
- 在代碼周圍放置 HTML 註釋
- 語言屬性
- 在同一頁面上使多個腳本正常工作
- 隱藏 JavaScript 源代碼
- 調試腳本
- 理解瀏覽器的內建錯誤報告
- 使用 alert
- 使用 try-catch
- 寫入頁面或窗口
- 使用外部調試器
- 嚴格警告
- 總結
- 處理數字
- 使用 JavaScript 進行數學運算
- 將數字四捨五入到 x 位小數
- 創建和限制隨機數
- 將數字轉換為字符串
- 格式化貨幣值
- 將字符串轉換為數字
- 將數字轉換為序數(-st, -nd, -rd, -th)
- 總結
- 處理字符串
- 在字符串中包含特殊字符
- 轉換字符串的字符大小寫
- 編碼 URL
- 比較兩個字符串
- 在字符串中查找子字符串
- 將字符串拆分為子字符串
- 創建正則表達式
- 測試字符串是否匹配正則表達式
- 測試字符串是否僅包含數字數據
- 測試字符串是否為有效的電話號碼
- 測試字符串是否為有效的電子郵件地址
- 使用正則表達式搜索和替換文本
- 總結
- 處理數組
- 使用數組字面量
- 創建數組的數組
- 使用字符串而非數字索引數組
- 將數組轉換為字符串
- 向數組添加或刪除成員
- 將數組按字母或數字順序排序
- 排序多維數組
- 隨機排序數組
- 總結
- 瀏覽文檔對象模型
- 訪問元素
- 創建元素和文本節點
- 更改元素的類型
- 刪除元素或文本節點
- 讀取和寫入元素的屬性
- 獲取所有具有特定屬性值的元素
- 向元素添加和刪除多個類
- 總結
- 處理和驗證表單
- 讀取和寫入文本字段中的數據
- 讀取和設置復選框的狀態
- 讀取和設置單選按鈕的狀態
- 讀取和設置選擇框的值
- 驗證必填文本字段
- 驗證數字字段
- 驗證電子郵件地址字段
- 檢查未選擇的單選按鈕
- 除非所有字段有效,否則停止提交表單
- 驗證字段數量未知的表單
- 在驗證表單時打印內聯錯誤消息
- 根據其他字段的值使表單字段顯示或隱藏
- 總結
- 處理窗口和框架
- 使用彈出窗口
- 彈出窗口有什麼問題?
- 如何最小化問題?
- 在新窗口中打開外部鏈接
- 在框架之間進行通信
- 獲取滾動位置
- 使頁面滾動到特定位置
- 獲取視口大小(窗口內的可用空間)
- 總結
- 處理 Cookies
- 寫入 Cookies
- 讀取 Cookie
- 設置 Cookie 在特定日期和時間過期
- 使 Cookie 僅從特定域或路徑訪問
- 繞過瀏覽器對可使用 Cookies 數量的限制
- 總結
- 處理日期和時間
- 獲取日期和時間
- 將日期格式化為句子
- 將時間格式化為 12 小時或 24 小時制
- 比較兩個日期
- 格式化日期之間的差異
- 總結
- 處理圖像
- 預加載圖像
- 用另一個圖像替換一個圖像
- 隨機顯示圖像
- 創建多個圖像的幻燈片放映
- 使圖像淡入或淡出
- 創建一個實時更新的基於圖像的時鐘
- 創建進度指示器
- 總結
- 檢測瀏覽器差異
- 確定對特定功能的支持
- 確定特定瀏覽器
- 檢測怪癖模式和標準模式
- 總結
- 使用 JavaScript 與 CSS
- 更改單個元素的樣式
- 更改一組元素的樣式
- 獲取元素的計算樣式
- 創建樣式表切換器
- 維護替代樣式表狀態
- 創建處理多媒體類型的樣式表切換器
- 讀取和修改現有樣式表
- 添加新的樣式表規則
- 從樣式表中刪除規則
- 創建新的樣式表
- 總結
- 基本動態 HTML
- 處理事件
- 簡單方法:使用事件處理程序
- W3C 方法(事件監聽器)
- 引用目標元素
- 什麼是事件冒泡,如何控制它?
- 查找元素的大小
- 查找元素的位置
- 檢測鼠標光標的位置
- 當鼠標懸停在元素上時顯示工具提示
- 按列對表格進行排序
- 總結
- 時間和運動
- 使用 setTimeout 和 setInterval
- 使對象沿著設置的路徑移動
- 使動畫不那麼顫動
- 動畫幀時間
- 在幀之間切換
- 動畫的複雜性
- 計算機的速度
- 瀏覽器的速度
- 實現拖放行為
- 使用拖放功能重新排序列表
- 創建滾動新聞報導
- 創建基於剪輯的過渡效果
- 創建滑塊控制
- 總結
- DHTML 菜單和導航
- 創建下拉或飛出菜單
- 添加箭頭以指示子菜單的存在
- 添加計時器以使菜單不會突然打開和關閉
- 確保菜單保持在窗口內
- 使菜單顯示在選定元素之上
- 創建文件夾樹或展開菜單
- 討論
- 在菜單中指示展開的分支
- 允許同時僅打開一個菜單分支
- 自動打開當前子分支
- 總結
- JavaScript 和可訪問性
- JavaScript 是否不可訪問?
- 什麼是可訪問性?
- 受影響的用戶是誰?
- 使腳本對鍵盤可訪問
- 使用設備無關的事件處理程序
- 使腳本同時對鍵盤和鼠標可訪問
- 滾動和顯示內容
- 表單驗證
- 拖放功能
- AJAX 和其他遠程腳本技術
- 使 title 屬性工具提示在獲得焦點時顯示
- 使 DHTML 菜單對鍵盤可訪問
- 使 DHTML 菜單可通過鍵盤使用
- 使 DHTML 滑塊控制對鍵盤可訪問
- 使腳本對屏幕閱讀器可訪問
- JavaScript 行為
- 滾動和顯示內容
- 表單驗證
- 非用戶啟動的腳本
- AJAX 和其他遠程腳本技術
- 技巧和黑客
- 朝著最佳實踐邁進
- 任務
- 模式的樂趣
- 朝著最佳實踐方法邁進
- 走向未來
- 總結
- 使用 JavaScript 與 Flash
- 檢測瀏覽器中是否安裝了 Flash
- 在 JavaScript 和 Flash 之間進行通信
- FSCommand
- Flash/JavaScript