Prentice Hall JavaScript by Example 2nd (2011).pdf
(
9066 KB
)
Pobierz
JavaScript by Example
Second Edition
JavaScript by Example
Second Edition
Ellie Quigley
PRENTICE
HALL
Upper Saddle River, NJ
Boston
Indianapolis
San Francisco
New York
Toronto
Montreal
London
Munich
Paris
Madrid
Capetown
Sydney
Tokyo
Singapore
Mexico City
Editor-in-Chief
Mark L. Taub
Managing Editor
John Fuller
Full-Service
Production Manager
Julie B. Nahll
Many of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Where those designations appear in this book,
and the publisher was aware of a trademark claim, the designations have been printed
with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no
expressed or implied warranty of any kind and assume no responsibility for errors or
omissions. No liability is assumed for incidental or consequential damages in
connection with or arising out of the use of the information or programs contained
herein.
Production Editor
Dmitri Korzh
Techne Group
Copy Editor
Teresa Horton
Indexer
Potomac Indexing, LLC
Proofreader
Beth Roberts
Editorial Assistant
Kim Boedlghelmer
Cover Designer
Anne Jones
Composition
Techne Group
The publisher offers excellent discounts on this book when ordered in quantity for
bulk purchases or special sales, which may include electronic versions and/or custom
covers and content particular to your business, training goals, marketing focus, and
branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside the United States, please contact:
International Sales
international@pearson.com
Visit us on the Web: informit.com/ph
Library of Congress
Cataloging-in-Publication
Data
Quigley, Ellie.
JavaScript by example / Ellie Quigley.—2nd ed.
p. cm.
Includes index.
ISBN 978-0-13-705489-3 (pbk. : alk. paper)
1. JavaScript (Computer program language) I. Title.
QA76.73.J39Q54 2010
005.133—dc22
2010020402
Copyright © 2011 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is
protected by copyright, and permission must be obtained from the publisher prior to
any prohibited reproduction, storage in a retrieval system, or transmission in any form
or by any means, electronic, mechanical, photocopying, recording, or likewise. For
information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
501 Boylston Street, Suite 900
Boston, MA 02116
Fax: (617) 671-3447
ISBN-13: 978-0-13-705489-3
ISBN-10: 0-13-705489-0
Text printed in the United States on recycled paper at Edwards Brothers in Ann Arbor,
Michigan.
First printing, October 2010
Contents
Preface xv
1
Introduction to JavaScript
1
1.1 What JavaScript Is 1
1.2 What JavaScript Is Not 2
1.3 What JavaScript Is Used For 3
1.4 JavaScript and Its Place in a Web Page
4
1.4.1
Analysis of the Diagram
4
1.5 What Is Ajax? 5
1.6 What JavaScript Looks Like 7
1.7 JavaScript and Its Role in Web Development
8
1.7.1
The Three Layers
8
1.8 JavaScript and Events
10
1.9
Standardizing JavaScript and the W3C
12
1.9.1
JavaScript Objects
13
1.9.2
The Document Object Model
13
1.10 What Browser? 15
1.10.1 Versions of JavaScript 16
1.10.2 Does Your Browser Follow the Standard?
1.10.3 Is JavaScript Enabled on Your Browser?
1.11 Where to Put JavaScript
20
1.11.1
JavaScript from External Files
22
1.12 Validating Your Markup
24
1.12.1
The W3C Validation Tool
24
1.12.2
The Validome Validation Tool
25
1.13 What You Should Know
26
Script Setup
29
2
2.1
The HTML Document and JavaScript
29
2.1.1
Script Execution
30
2.2
Syntactical Details
33
2.2.1
Case Sensitivity
33
2.2.2
Free Form and Reserved Words
33
2.2.3
Statements and Semicolons
34
2.2.4
Comments
35
2.2.5
The
<script>
Tag
35
2.3
Generating HTML and Printing Output
37
2.3.1
Strings and String Concatenation
37
2.3.2
The
write0
and
writelnQ
Methods
38
2.4
About Debugging
40
2.4.1
Types of Errors
40
2.5
Debugging Tools
41
2.5.1
Firefox
41
2.5.2
Debugging in Internet Explorer 8
44
2.5.3 The
JavaScript:
URL Protocol 46
2.6 JavaScript and Old or Disabled Browsers
47
2.6.1
Hiding JavaScript from Old Browsers
47
2.7
What You Should Know
50
3 The Building Blocks: Data Types, Literals, and Variables
53
3.1
Data Types
53
3.1.1
Primitive Data Types
53
3.1.2
Composite Data Types
59
3.2
Variables
59
3.2.1
Valid Names
60
3.2.2
Declaring and Initializing Variables
60
3.2.3
Dynamically or Loosely Typed Language
62
3.2.4
Scope of Variables
66
3.2.5
Concatenation and Variables
66
3.3
Constants
67
3.4
Bugs to Watch For
69
3.5
What You Should Know
70
4
Dialog Boxes
73
4.1
Interacting with the User
73
4.1.1
The
alertO
Method
73
4.1.2
The
prompt ()
Method
76
4.1.3
The
confirm()
Method
78
A
n rl
r
1
1 J
OA
7
Plik z chomika:
Stefan_68
Inne pliki z tego folderu:
OReilly Head First JavaScript (2008).pdf
(51807 KB)
Apress Pro JavaScript Techniques (2006).pdf
(3318 KB)
OReilly JavaScript and jQuery, The Missing Manual 2nd (2012).pdf
(15996 KB)
No Starch Press Eloquent JavaScript, A Modern Introduction to Programming (2011).pdf
(1817 KB)
OReilly Building iPhone Apps with HTML CSS and JavaScript (2010).pdf
(4316 KB)
Inne foldery tego chomika:
3D Printing
AJAX eBooks Collection
Art, Draw & Paint eBooks Collection
Artificial Intelligence
Artificial.Intelligence.Lisp.Prolog
Zgłoś jeśli
naruszono regulamin