Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
JavaScript Step by Step
Dedication
A Note Regarding Supplemental Files
Introduction
Who should read this book
Assumptions
Who should not read this book
Organization of this book
Conventions and features in this book
System requirements
Code Samples
Installing the Code Samples
Using the Code Samples
Acknowledgments
Errata & Book Support
We Want to Hear from You
Stay in Touch
I. Javawhat? The where, why, and how of JavaScript
1. JavaScript is more than you might think
A brief history of JavaScript
Enter Internet Explorer 3.0
And then came ECMAScript
So many standards...
The DOM
What’s in a JavaScript program?
JavaScript placement on your webpage
What JavaScript can do
What JavaScript can’t do
JavaScript can’t be forced on a client
JavaScript can’t guarantee data security
JavaScript can’t cross domains
JavaScript doesn’t do servers
Tips for using JavaScript
Where JavaScript fits
Which browsers should the site support?
And then came Windows 8
Exercises
2. Developing in JavaScript
JavaScript development options
Configuring your environment
Writing JavaScript with Visual Studio 2012
Your first web (and JavaScript) project with Visual Studio 2012
Using external JavaScript files with Visual Studio 2012
Debugging JavaScript
Exercises
3. JavaScript syntax and statements
A bit of housekeeping
Case sensitivity
White space
Comments
Semicolons
Line breaks
Placing JavaScript correctly
JavaScript statements
What’s in a statement?
The two types of JavaScript statements
Reserved words in JavaScript
A quick look at functions
JavaScript’s strict mode
Exercises
4. Working with variables and data types
Data types in JavaScript
Working with numbers
Numeric functions
The Math object
Working with strings
Escaping quotation marks
Other escape characters
String methods and properties
Booleans
Null
Undefined
Objects
Arrays
Defining and using variables
Declaring variables
Variable types
Variable scope
The Date object
Using the RegExp object
The syntax of regular expressions
References and garbage collection
Learning about type conversions
Number conversions
String conversions
Boolean conversions
Exercises
5. Using operators and expressions
Meet the operators
Additive operators
Multiplicative operators
Bitwise operators
Equality operators
Relational operators
The in operator
The instanceof operator
Unary operators
Incrementing and decrementing
Converting to a number with the plus sign
Creating a negative number with the minus sign
Negating with bitwise not and logical not
Using the delete operator
Returning variable types with the typeof operator
Assignment operators
The importance of byte conservation (a.k.a. minification)
The comma operator
Exercises
6. Controlling flow with conditionals and loops
If (and how)
Syntax for if statements
The prompt() function in Internet Explorer
Compound conditions
Using else if and else statements
Working with ternary conditionals
Testing with switch
Looping with while
The while statement
Making sure the code executes at least once
Changing the condition
The do...while statement
Using for loops
The for loop
The for...in loop
The for each...in loop
Validating forms with conditionals
Exercises
7. Working with functions
What’s in a function?
Function parameters
Variable scoping revisited
Return values
More on calling functions
Anonymous/unnamed functions (function literals)
Closures
Methods
A look at dialog functions
Exercises
8. Objects in JavaScript
Object-oriented development
Objects
Properties
Methods
Classes
Creating objects
Adding properties to objects
Displaying object properties
Looking for a property
Adding methods to objects
Finding out more about arrays
The length property
Array methods
Using concat() to add elements
Joining and concatenating with join
Using push and pop to add and remove elements
Using shift and unshift to add and remove elements
Using slice() to return parts of an array
Sorting elements with sort()
Iterating through arrays
Taking advantage of built-in objects
Making URIs safe
Using the eval() method
Exercises
9. The Browser Object Model
Introducing the browser
The browser hierarchy
Events
A sense of self
Getting information about the screen
Using the navigator object
The location object
The history object
Exercises
10. An introduction to JavaScript libraries and frameworks
Understanding programming libraries
Defining your own JavaScript library
Looking at popular JavaScript libraries and frameworks
jQuery
Modernizr
Yahoo! User Interface
MooTools
Other libraries
Exercises
11. An introduction to jQuery
jQuery primer
Using jQuery
The two jQuery downloads
Including jQuery
Basic jQuery syntax
Connecting jQuery to the load event
Using selectors
Selecting elements by ID
Selecting elements by class
Selecting elements by type
Selecting elements by hierarchy
Selecting elements by position
Selecting elements by attribute
Selecting form elements
More selectors
Functions
Traversing the DOM
Working with attributes
Changing text and HTML
Inserting elements
Callback functions
More jQuery
Exercises
II. Integrating JavaScript into Design
12. The Document Object Model
The Document Object Model defined
DOM Level 0: The legacy DOM
DOM Levels 1 through 3
The DOM as a tree
Working with nodes
Retrieving elements
Retrieving elements by ID
Retrieving by tag name
HTML collections
Working with siblings
Working with attributes
Viewing attributes
Setting attributes
Creating elements
Adding text
Adding an element and setting an ID
Deleting elements
Exercises
13. JavaScript events and the browser
Understanding window events
The event models
Using the DOM 0 model
Newer event models: W3C and Internet Explorer
A generic event handler
jQuery event handling
Binding and unbinding
Detecting visitor information
A brief look at the userAgent property
Feature testing
Keeping JavaScript away from older browsers
Other navigator properties and methods
Opening, closing, and resizing windows
Window opening best practices
Opening tabs: no JavaScript necessary
Resizing and moving windows
Timers
Events
Mouse events and hover
Many more event handlers
Exercises
14. Working with images in JavaScript
Working with image hovers
A simple hover
Modern hovers with jQuery
A closer look at the exercise
Preloading images
Working with slide shows
Creating a slide show
Moving backward
A jQuery slide show
Working with image maps
Exercises
15. Using JavaScript with web forms
JavaScript and web forms
Validation with JavaScript
Validation with jQuery
Working with form information
Working with select boxes
Working with check boxes
Working with radio buttons
Pre-validating form data
Hacking JavaScript validation
Validating a text field
Exercises
16. JavaScript and CSS
What is CSS?
Using properties and selectors
Applying CSS
The relationship between JavaScript and CSS
Setting element styles by ID
Setting element styles by type
Setting CSS classes with JavaScript
Retrieving element styles with JavaScript
Exercises
17. jQuery effects and plug-ins
Installing jQuery UI
Obtaining jQuery UI
Installing jQuery UI
Building a jQuery UI demonstration page
Creating a jQuery UI calendar
Customizing the calendar
Adding buttons
Displaying multiple months
Adding month and year drop-down lists
Limiting the date range
Adding a dialog box
Creating a modal dialog
Adding buttons
More JQuery UI
Exercises
18. Mobile development with jQuery Mobile
A walkthrough of jQuery Mobile
Getting jQuery Mobile
Downloading jQuery Mobile
Testing jQuery Mobile
Linking with jQuery Mobile
Creating a link
Changing the page transition
Linking without AJAX
Enhancing the page with toolbars
Adding a navigation bar
Adding a footer navigation bar
Adding buttons to toolbars
Other toolbar enhancements
Changing the toolbar color
Persistent toolbar
Even more jQuery Mobile
Exercises
19. Getting data into JavaScript
JavaScript application architecture
The big three: display, behavior, data
Display: page layout
Behavior: controlling what happens when
Data: consume, display, and validate
JavaScript and web interfaces
Introduction to AJAX
AJAX with jQuery
AJAX without the X
What’s Next?
III. AJAX and Server-Side Integration
20. Using AJAX
The XMLHttpRequest object
Instantiating the XMLHttpRequest object
Sending an AJAX request
Processing an AJAX response
Processing XML responses
Working with JSON
Processing headers
Using the POST method
AJAX and jQuery
AJAX errors and time-outs
Sending data to the server
Other important options
Exercise
21. Developing for Windows 8
Windows 8 apps
Developing Windows 8 apps
Development guidelines
The development process
Planning and designing the app
Developing the app
Packaging and testing the app
Distributing Windows apps
Distributing in the Windows Store
Distributing in an enterprise
Summary
IV. JavaScript and Windows 8
22. Using Visual Studio for Windows 8 development
Installing Visual Studio 2012
Installing Visual Studio 2012 Express for Windows 8
Windows 8 app templates
Blank App template
Grid App template
Split App template
Setting app details in the App Manifest
Packaging apps for the Windows Store
Certification requirements
How do I make money?
The technical process
Exercises
23. Creating a Windows app
The app development process
Starting the app design and programming
Customizing the app
Customize the JavaScript
Customize the main HTML
Customize the detail HTML
Customize the CSS
Finalizing the app
Customizing the Package Manifest
Adding a splash screen, logo, and tile image
Defining capabilities
Testing the app
Summary
A. Answer key to exercises
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Chapter 18
Chapter 19
Chapter 20
Chapter 21
Chapter 22
Chapter 23
B. Writing JavaScript with other tools
Writing JavaScript with Eclipse
Your first web (and JavaScript) project with Eclipse
Using external JavaScript files with Eclipse
Writing JavaScript without an IDE
Your first web (and JavaScript) project with Notepad
Using external JavaScript files without an IDE
C. About the Author
Index
About the Author
Copyright
← Prev
Back
Next →
← Prev
Back
Next →