The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks

Free Download

Authors:

Edition: 1

ISBN: 9780975240267, 0975240269

Size: 3 MB (3135155 bytes)

Pages: 612/612

File format:

Language:

Publishing Year:

Category:

Cameron Adams, James Edwards9780975240267, 0975240269

Using a cookbook approach, The “JavaScript Anthology will show you how to apply JavaScript to solve a multitude of common Web Development challenges. You’ll get answers to 101 questions ranging from “How can I format the time into a 12 or 24-hour clock?” to “How can I make my scripts run faster?”Included in this book is extensive coverage of DHTML and AJAX, including how-to create and customize advanced effects such as draggable elements, dynamically sorting data in a Web Browser, advanced menu systems, retrieving data from a Web Server using XML Http Request and more.The “JavaScript Anthology also includes extensive coverage of object oriented coding, efficient script design, accessibility, and cross-browser issues. Best of all, you’ll get download access to all the code used in the book, so you can put the scripts to use instantly.

Table of contents :
The JavaScript Anthology……Page 5
Table of Contents……Page 11
Who Should Read this Book?……Page 19
What’s in this Book?……Page 20
The SitePoint Forums……Page 23
Ackn_ßgÃ)̶CËØ«>@ƒ……Page 24
JavaScript Defined……Page 25
JavaScript’s Limitations……Page 26
FSCommand……Page 0
Providing for Users who Don’t Have JavaScript (Progressive Enhancement)……Page 29
Separating Content from BehaF⁄¸‹ªá-Kł8Võ¤Ì€¦»^š}S
{Ùñ¦……Page 32
Using Braces Qh3ôå·`œ¤D`IÇÿM2ÁöB@d”qÚjk¸LϯÂV¸éð¥ øEÀLÃÈìòK€E©¦=……Page 103
AccessY#[=,Ó·¬çÐÐËq……Page 106
Creating Elements and Text Nodes……Page 111
Changing the Type of an Element……Page 115
Re]CôŽÛڢݬVœ~æ&y­ZÁsü⁄¢¤Ó¤ºä¯@š……Page 117
Reading QhžmÀÿ…Ë¡‘ÕÛšŸí6_H_á÷Ò“Ží− c‘’/Ñ{“8Š}……Page 119
Getting all Elements with a Particular Attribute Value……Page 122
Adding and Removing Multiple Classes to/from an Element……Page 124
Processing and Validating Forms……Page 127
Reading and Setting the State of a Checkbox……Page 130
Reading and Setting the State of a Radio Button……Page 133
Reading and Setting the Value of a Select Box……Page 135
Validating a Mandatory Text Field……Page 137
Validating a Numeric Field……Page 138
Checking for Unselected Radio Buttons……Page 139
Stopping a Form Being Submitted Unless all its Fields are Valid……Page 140
Validating a Form with an Unknown Number of Fields……Page 141
Printing Inline Error Messages when Validating a Form……Page 143
Making Form Fields Appear or Disappear, Based on the Value of other Fields……Page 145
Summary……Page 149
Working with Windows and Frames……Page 151
What’s Wrong with Popups?……Page 152
How Do I Minimize the Problems?……Page 153
Opening Off-site Links in a New WinTárA……Page 157
Communicating Between Frames……Page 159
Getting the Scrolling Position……Page 161
Making the Page Scroll to a Particular Position……Page 164
Getting the Viewport Size (the Available Space inside the Window)……Page 165
Summary……Page 166
Writing Cookies……Page 167
Reading a Cookie……Page 169
Setting a Cookie to Expire at a Specific Date and Time……Page 170
Making a Cookie Accessible Only from a Specific Domain or Path……Page 171
Circumventing Browser Restrictions on the Number of Cookies you can Use……Page 172
Summary……Page 174
Getting the Date and Time……Page 175
Formatting a Date into a Sentence……Page 178
Formatting the Time into a 12- or 24-hour Clock……Page 181
Comparing Two Dates……Page 183
Formatting the Difference Between DaD¨Ò……Page 188
Summary……Page 190
Preloading ImaW«(Łp……Page 191
Swapping One Image for Another……Page 193
Displaying an Image at Random……Page 195
Making a Slideshow of Several Images……Page 197
Making an Image Fade in or out……Page 200
Making an Image-based Clock that Updates in Real Time……Page 205
Making a Progress Indicator……Page 210
Summary……Page 213
Detecting Browser Differences……Page 215
Identifying Support for a Particular Feature……Page 216
Identifying a Particular Browser……Page 218
Detecting Quirks Mode and Standards Mode……Page 222
Summary……Page 224
Changing the Style of a Single Element……Page 225
Changing the Style of a Group of Elements……Page 227
Retrieving the Computed Style of an Element……Page 228
Making a Style Sheet Switcher……Page 231
Maintaining Alternate Style Sheet States……Page 236
Making a Style Sheet Switcher that Handles Multiple Media Types……Page 239
Reading and Modifying an Existing Style Sheet……Page 241
Adding New Style Sheet Rules……Page 244
Deleting a Rule from a Style Sheet……Page 247
Creating a New Style Sheet……Page 248
Summary……Page 251
Basic Dynamic HTML……Page 253
The Short Way: Using Event Handlers……Page 254
The W3C Way (Event Listeners)……Page 257
Referencing the Target Element……Page 262
What is Event Bubbling, and How do I Control it?……Page 267
Finding the Size of an Element……Page 269
Finding the Position of an Element……Page 270
Detecting the Position of the Mouse Cursor……Page 272
Displaying a Tooltip when you Mouse Over an Element……Page 274
Sorting Tables by Column……Page 281
Summary……Page 290
Using setTimeout and setInterval……Page 291
Making an Object Move Along a Set Path……Page 294
Making Animation Less Jerky……Page 302
Changing Between Frames……Page 303
The Speed of the Computer……Page 304
y†Ä
²1Ö#ž­®¶†@††:$$Zâq=Gê«·áô©©>¦……Page 305
Re_
é%O±Ó¤û−™>ôHCå*¾ÍŸžÛ%P&x`50ôÚnłÍGÏ@ßa>e{……Page 314
Making a Scrolling News Ticker……Page 322
Creating Clip-based Transition Effects……Page 329
Making a Slider Control……Page 335
Summary……Page 342
DHTML Menus and Navigation……Page 345
Making a Drop-down or Fly-out Menu……Page 347
Adding Arrows to Indicate the Presence of a Submenu……Page 358
Adding Timers so the Menus Don’t Open and Close so Abruptly……Page 362
Making Sure tXKÕ¾
!wsQ;f
KÜ»ƒ€U+Ɇì1ü€ıœo……Page 369
Making the Menus Display Over select Elements……Page 378
Making a Folder Tree or Expanding Menu……Page 385
Indicating Expanded Branches in a Menu……Page 395
Allowing Only OnU(¥gŁ‰1®Iı
ú›Hãʆs³†dôŠ/‘(•xPłŠ……Page 401
Opening the Current Sub-branch Automatically……Page 402
Summary……Page 407
JavaScript and AcSM›=ZL‹|¶fl/ë……Page 409
What is Accessibility?……Page 410
Who are the Affected Users?……Page 411
Making Scripts Accessible to the Keyboard……Page 413
Using DevicUr†’œ¢^ú%ß‚‚vhýYRùñì§II/å’©……Page 417
Making Scripts Accessible to the Keyboard as well as the Mouse……Page 419
Rollovers and Revealing Content……Page 420
Form Validation……Page 422
Drag-and-drop Functionality……Page 424
AJAX and other Remote Scripting Techniques……Page 425
Making title Attribute Tooltips tëwâ²LºÊ¹hÕ&e“ı……Page 426
Making a DHTML Menu Accessible to the Keyboard……Page 435
Making a DHTML Menu Usable via the Keyboard……Page 445
Making a DHTML Slider Control Accessible to the Keyboard……Page 452
Making Scripts Accessible to Screen Readers……Page 460
JavaScript Behaviors……Page 462
Rollovers and Revealing Content……Page 463
Form Validation……Page 464
Non-user-initiated Scripts……Page 465
AJAX and other Remote Scripting Techniques……Page 470
Tricks and Hacks……Page 473
Reaching toward a Best Practice Approach……Page 478
Using JavaScript with Flash……Page 481
Communicating Between JavaScriptläØ)情:……Page 485
Flash/JavaScript Integration Kit……Page 488
Summary……Page 489
Building Web Applications with JavaScript……Page 491
Retrieving Data Using XMLHttpRequest……Page 492
Requesting Data from a Server……Page 494
Parsing the Data……Page 497
Caching……Page 499
Retrieving Data without Using XMLHttpRequest……Page 500
Creating Custom Dialogs (Such as Popup Forms)……Page 505
Creating Editable Elements……Page 513
Controlling Text Selections……Page 520
Creating an Auto-complete Text Field……Page 526
Summary……Page 538
Object Orientation in JavaScript……Page 539
Encapsulation……Page 540
Class Inheritance……Page 541
Object Based Code vs Object Oriented Code……Page 542
Writing an Object Oriented Script……Page 543
Creating Methods for an ObZxE!ä[……Page 545
Prototype-based Method Creation……Page 546
Modelling Inheritance……Page 550
Understanding Scope……Page 552
Implementing Namespaces……Page 555
Summary……Page 557
Keeping up the Pace……Page 559
Saving References to Objects you Use Frequently……Page 560
Using Ternary Operators and Switch Statements……Page 563
Optimizing Loops……Page 566
Avoiding eval……Page 567
Avoiding Strict Warnings……Page 568
Optimizing for a Particular Browser……Page 569
Dividing Tasks into Functions (or Using OO)……Page 572
Using Arrays and Iteration to Avoid Code Repetition……Page 574
Compacting Conditions and Return StatemU{iFýÄ……Page 575
Removing Comments and Unnecessary Whitespace……Page 576
Compacting the Names of Variables and Properties……Page 579
Avoiding Memory Leaks……Page 580
Avoiding Circular References……Page 581
Cleaning Up After the Fact……Page 582
Making Scripts Run Before the Load Event……Page 584
Summary……Page 587
Index……Page 589

Reviews

There are no reviews yet.

Be the first to review “The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks”
Shopping Cart
Scroll to Top