100% found this document useful (1 vote)
20 views

JavaScript for Programmers 1st Edition Paul J. Deitel instant download

The document provides links to various programming eBooks available for download, including titles by Paul J. Deitel and others. It features resources on JavaScript, C, and Android programming, among others. Additionally, it includes information about Deitel's publishing program and various educational resources for programmers.

Uploaded by

cisserjasri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
20 views

JavaScript for Programmers 1st Edition Paul J. Deitel instant download

The document provides links to various programming eBooks available for download, including titles by Paul J. Deitel and others. It features resources on JavaScript, C, and Android programming, among others. Additionally, it includes information about Deitel's publishing program and various educational resources for programmers.

Uploaded by

cisserjasri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

JavaScript for Programmers 1st Edition Paul J.

Deitel pdf download

https://ebookgate.com/product/javascript-for-programmers-1st-
edition-paul-j-deitel/

Get Instant Ebook Downloads – Browse at https://ebookgate.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

C 20 for Programmers 3rd Edition P. Deitel

https://ebookgate.com/product/c-20-for-programmers-3rd-edition-p-
deitel/

ebookgate.com

JavaScript for impatient programmers ES2020 edition Dr.


Axel Rauschmayer

https://ebookgate.com/product/javascript-for-impatient-programmers-
es2020-edition-dr-axel-rauschmayer/

ebookgate.com

C How to Program 7th Edition Paul J. Deitel

https://ebookgate.com/product/c-how-to-program-7th-edition-paul-j-
deitel/

ebookgate.com

Herding Cats A Primer for Programmers Who Lead Programmers


1st Edition J. Hank Rainwater

https://ebookgate.com/product/herding-cats-a-primer-for-programmers-
who-lead-programmers-1st-edition-j-hank-rainwater/

ebookgate.com
C How to Program 6th Edition Paul Deitel

https://ebookgate.com/product/c-how-to-program-6th-edition-paul-
deitel/

ebookgate.com

Android How to Program 2nd Edition Paul Deitel

https://ebookgate.com/product/android-how-to-program-2nd-edition-paul-
deitel/

ebookgate.com

C How to Program 9e 9th Edition Paul Deitel

https://ebookgate.com/product/c-how-to-program-9e-9th-edition-paul-
deitel/

ebookgate.com

Learning the iPhone SDK for JavaScript Programmers Create


Native Apps with Objective C and Xcode 1st Edition Danny
Goodman
https://ebookgate.com/product/learning-the-iphone-sdk-for-javascript-
programmers-create-native-apps-with-objective-c-and-xcode-1st-edition-
danny-goodman/
ebookgate.com

Learning the iOS 4 SDK for JavaScript Programmers Create


Native Apps with Objective C and Xcode 1st Edition Goodman

https://ebookgate.com/product/learning-the-ios-4-sdk-for-javascript-
programmers-create-native-apps-with-objective-c-and-xcode-1st-edition-
goodman/
ebookgate.com
JAVASCRIPT™
FOR PROGRAMMERS
DEITEL® DEVELOPER SERIES
De i te l ® Se r
How to Program Series
Java How to Program, 7/E
C++ How to Program, 6/E
Visual C++® 2008 How to Program, 2/E
C How to Program, 5/E
Internet & World Wide Web How to Program, 4/E
Visual Basic® 2008 How to Program
Visual C#® 2008 How to Program, 3/E
Small Java™ How to Program, 6/E
Small C++ How to Program, 5/E

Simply Series
Simply C++: An Application-Driven Simply C#: An Application-Driven
Tutorial Approach Tutorial Approach
Simply Java™ Programming: An Simply Visual Basic® 2008, 3/E: An
Application-Driven Tutorial Application-Driven Tutorial
Approach Approach

SafariX Web Books


www.deitel.com/books/SafariX.html
C++ How to Program, 5/E & 6/E Small C++ How to Program, 5/E
Java How to Program, 6/E & 7/E Small Java How to Program, 6/E
Simply C++: An Application-Driven Visual Basic 2008 How to Program
Tutorial Approach Visual C# 2008 How to Program, 3/E
Simply Visual Basic 2008: An
Application-Driven Tutorial
Approach, 3/E
ies Page
Deitel® Developer Series
AJAX, Rich Internet Applications and C# 2008 for Programmers, 3/E
Web Development for Programmers Java for Programmers
C++ for Programmers Javascript for Programmers

LiveLessons Video Learning


Products
www.deitel.com/books/LiveLessons/
Java Fundamentals Parts 1 and 2 C++ Fundamentals Parts 1 and 2
C# Fundamentals Parts 1 and 2 JavaScript Fundamentals Parts 1 and 2

To follow the Deitel publishing program, please register for the free Deitel® Buzz
Online e-mail newsletter at:
www.deitel.com/newsletter/subscribe.html

To communicate with the authors, send e-mail to:


deitel@deitel.com

For information on government and corporate Dive-Into® Series on-site seminars


offered by Deitel & Associates, Inc. worldwide, visit:
www.deitel.com/training/

or write to
deitel@deitel.com

For continuing updates on Prentice Hall/Deitel publications visit:


www.deitel.com
www.prenhall.com/deitel

Check out our Resource Centers for valuable web resources that will help you master
Visual C#, other important programming languages, software and Internet- and web-
related topics:
www.deitel.com/ResourceCenters.html
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 authors 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.
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 U. S., please contact:
International Sales
international@pearsoned.com
Visit us on the Web: www.phptr.com

Library of Congress Cataloging-in-Publication Data


On file
© 2010 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
One Lake Street
Upper Saddle River, NJ 07458
ISBN 0-13-700131-2

Text printed in the United States on recycled paper at R.R . Donnelley in Crawfordsville, Indiana.
First printing, February 2009
JAVASCRIPT™ FOR
PROGRAMMERS
DEITEL® DEVELOPER SERIES

Paul J. Deitel
Deitel & Associates, Inc.

Harvey M. Deitel
Deitel & Associates, Inc.

Upper Saddle River, NJ • Boston • Indianapolis • San Francisco


New York • Toronto • Montreal • London • Munich • Paris • Madrid
Capetown • Sydney • Tokyo • Singapore • Mexico City
Trademarks
DEITEL, the double-thumbs-up bug and DIVE INTO are registered trademarks of Deitel & Associates,
Inc.
Apache is a trademark of The Apache Software Foundation.
CSS, DOM, XHTML and XML are registered trademarks of the World Wide Web Consortium.
Firefox is a registered trademark of the Mozilla Foundation.
Google is a trademark of Google, Inc.
JavaScript, Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc.
in the United States and other countries.
Microsoft, Internet Explorer and the Windows logo are either registered trademarks or trademarks of
Microsoft Corporation in the United States and/or other countries.
MySpace is a registered trademark of MySpace.com.
UNIX is a registered trademark of The Open Group.
Web 2.0 is a service mark of CMP Media.
Wikipedia is a registered trademark of WikiMedia.

Throughout this book, trademarks are used. Rather than put a trademark symbol in every occurrence of
a trademarked name, we state that we are using the names in an editorial fashion only and to the benefit
of the trademark owner, with no intention of infringement of the trademark.
To Brendan Eich:
For creating the JavaScript language while at
Netscape Communications Corporation.

Paul and Harvey Deitel


Deitel Resource Centers
Our Resource Centers focus on the vast amounts of free content available online. Find resources,
downloads, tutorials, documentation, books, e-books, journals, articles, blogs, RSS feeds and more
on many of today’s hottest programming and technology topics. For the most up-to-date list of our
Resource Centers, visit:
www.deitel.com/ResourceCenters.html
Let us know what other Resource Centers you’d like to see! Also, please register for the free Deitel®
Buzz Online e-mail newsletter at:
www.deitel.com/newsletter/subscribe.html
Computer Science Silverlight Java SE 7 (Dolphin) SharePoint
Functional Programming Visual Basic Resource Center Skype
Regular Expressions Visual C++ JavaFX Web Servers
Visual Studio Team Sys- Wikis
Programming tem Microsoft Windows Vista
ASP.NET 3.5 Web 3D Technologies ASP.NET
Adobe Flex Web Services ASP.NET 3.5 Web 2.0
Ajax Windows Presentation ASP.NET Ajax Alert Services
Apex Foundation C# Attention Economy
ASP.NET Ajax XHTML DotNetNuke (DNN) Blogging
ASP.NET XML Internet Explorer 7 (IE7) Building Web
C Microsoft LINQ Communities
C++ Games and Game .NET Community Generated
C++ Boost Libraries Programming .NET 3.0 Content
C++ Game Programming Computer Game Pro- .NET 3.5 Facebook Developer
C# gramming SharePoint Platform
Code Search Engines and Computer Games Silverlight Facebook Social Ads
Code Sites Mobile Gaming Visual Basic Google Base
Computer Game Sudoku Visual C++ Google Video
Programming Visual Studio Team Google Web Toolkit
CSS 2.1 Internet Business System (GWT)
Dojo Affiliate Programs Windows Presentation Internet Video
Facebook Developer Plat- Competitive Analysis Foundation Joost
form Facebook Social Ads Windows Vista Location-Based Services
Flash 9 Google AdSense Microsoft Popfly Mashups
Functional Programming Google Analytics Microformats
Java Google Services Open Source & Recommender Systems
Java Certification and Internet Advertising LAMP Stack RSS
Assessment Testing Internet Business Apache Social Graph
Java Design Patterns Initiative DotNetNuke (DNN) Social Media
Java EE 5 Internet Public Relations Eclipse Social Networking
Java SE 6 Link Building Firefox Software as a Service
Java SE 7 (Dolphin) Location-Based Services Linux (SaaS)
Resource Center Online Lead Generation MySQL Virtual Worlds
JavaFX Podcasting Open Source Web 2.0
JavaScript Search Engine Optimiza- Perl Web 3.0
JSON tion PHP Widgets
Microsoft LINQ Selling Digital Content Python
Microsoft Popfly Sitemaps Ruby Dive Into® Web 2.0
.NET Web Analytics eBook
.NET 3.0 Website Monetization Software Web 2 eBook
.NET 3.5 YouTube and AdSense Apache
OpenGL DotNetNuke (DNN) Other Topics
Perl Java Eclipse Computer Games
PHP Java Firefox Computing Jobs
Programming Projects Java Certification and Internet Explorer 7 (IE7) Gadgets and Gizmos
Python Assessment Testing Linux Ring Tones
Regular Expressions Java Design Patterns MySQL Sudoku
Ruby Java EE 5 Open Source
Ruby on Rails Java SE 6 Search Engines
Contents

Preface xv

Before You Begin xxiii

1 Introduction 1
1.1 Introduction 2
1.2 History of the Internet and World Wide Web 3
1.3 World Wide Web Consortium (W3C) 5
1.4 Web 2.0 5
1.5 Key Software Trend: Object Technology 7
1.6 JavaScript: Object-Based Scripting for the Web 8
1.7 Browser Portability 9
1.8 Web Resources 9

2 Introduction to XHTML 10
2.1 Introduction 11
2.2 Editing XHTML 12
2.3 First XHTML Example 12
2.4 W3C XHTML Validation Service 15
2.5 Headings 15
2.6 Linking 16
2.7 Images 19
2.8 Special Characters and Horizontal Rules 22
2.9 Lists 24
2.10 Tables 27
2.11 Forms 31
2.12 Internal Linking 38
2.13 meta Elements 40
2.14 Web Resources 42

3 Cascading Style Sheets™ (CSS) 43


3.1 Introduction 44
3.2 Inline Styles 45
3.3 Embedded Style Sheets 46
3.4 Conflicting Styles 49
x Contents

3.5 Linking External Style Sheets 52


3.6 Positioning Elements 54
3.7 Backgrounds 58
3.8 Element Dimensions 59
3.9 Box Model and Text Flow 61
3.10 Media Types 65
3.11 Building a CSS Drop-Down Menu 67
3.12 User Style Sheets 69
3.13 CSS 3 73
3.14 Web Resources 73

4 JavaScript: Introduction to Scripting 74


4.1 Introduction 75
4.2 Simple Program: Displaying a Line of Text in a Web Page 76
4.3 Modifying Our First Program 79
4.4 Obtaining User Input with prompt Dialogs 84
4.4.1 Dynamic Welcome Page 84
4.4.2 Adding Integers 88
4.5 Data Types in JavaScript 90
4.6 Arithmetic 90
4.7 Decision Making: Equality and Relational Operators 91
4.8 Web Resources 95

5 JavaScript: Control Statements I 96


5.1 Introduction 97
5.2 Control Statements 97
5.3 if Selection Statement 98
5.4 if…else Selection Statement 99
5.5 while Repetition Statement 103
5.6 Counter-Controlled Repetition 104
5.7 Formulating Algorithms: Sentinel-Controlled Repetition 106
5.8 Formulating Algorithms: Nested Control Statements 109
5.9 Assignment Operators 112
5.10 Increment and Decrement Operators 113
5.11 Web Resources 116

6 JavaScript: Control Statements II 117


6.1 Introduction 118
6.2 Essentials of Counter-Controlled Repetition 118
6.3 for Repetition Statement 120
6.4 Examples Using the for Statement 124
6.5 switch Multiple-Selection Statement 128
6.6 do…while Repetition Statement 133
6.7 break and continue Statements 135
Contents xi

6.8 Labeled break and continue Statements 138


6.9 Logical Operators 140

7 JavaScript: Functions 145


7.1 Introduction 146
7.2 Functions 146
7.3 Programmer-Defined Functions 147
7.4 Function Definitions 147
7.5 Random Number Generation 152
7.6 Example: Game of Chance 157
7.7 Another Example: Random Image Generator 163
7.8 Scope Rules 165
7.9 JavaScript Global Functions 167
7.10 Recursion 168
7.11 Recursion vs. Iteration 172

8 JavaScript: Arrays 173


8.1 Introduction 174
8.2 Arrays 174
8.3 Declaring and Allocating Arrays 175
8.4 Examples Using Arrays 176
8.5 Random Image Generator Using Arrays 183
8.6 References and Reference Parameters 184
8.7 Passing Arrays to Functions 185
8.8 Sorting Arrays 188
8.9 Multidimensional Arrays 190
8.10 Building an Online Quiz 194

9 JavaScript: Objects 197


9.1 Introduction 198
9.2 Introduction to Object Technology 198
9.3 Math Object 201
9.4 String Object 202
9.4.1 Fundamentals of Characters and Strings 202
9.4.2 Methods of the String Object 203
9.4.3 Character-Processing Methods 205
9.4.4 Searching Methods 206
9.4.5 Splitting Strings and Obtaining Substrings 209
9.4.6 XHTML Markup Methods 210
9.5 Date Object 213
9.6 Boolean and Number Objects 218
9.7 document Object 219
9.8 window Object 220
9.9 Using Cookies 225
xii Contents

9.10 Multipage HTML and JavaScript Application 229


9.11 Using JSON to Represent Objects 237

10 Document Object Model (DOM):


Objects and Collections 238
10.1 Introduction 239
10.2 Modeling a Document: DOM Nodes and Trees 239
10.3 Traversing and Modifying a DOM Tree 242
10.4 DOM Collections 253
10.5 Dynamic Styles 255
10.6 Summary of the DOM Objects and Collections 261

11 JavaScript: Events 263


11.1 Introduction 264
11.2 Registering Event Handlers 264
11.3 Event onload 267
11.4 Event onmousemove, the event Object and this 268
11.5 Rollovers with onmouseover and onmouseout 273
11.6 Form Processing with onfocus and onblur 277
11.7 Form Processing with onsubmit and onreset 280
11.8 Event Bubbling 282
11.9 More Events 284
11.10 Web Resources 285

12 XML and RSS 286


12.1 Introduction 287
12.2 XML Basics 287
12.3 Structuring Data 290
12.4 XML Namespaces 297
12.5 Document Type Definitions (DTDs) 300
12.6 W3C XML Schema Documents 304
12.7 XML Vocabularies 310
12.7.1 MathML™ 311
12.7.2 Other Markup Languages 314
12.8 Extensible Stylesheet Language and XSL Transformations 314
12.9 Document Object Model (DOM) 324
12.10 RSS 342
12.11 Web Resources 349

13 Ajax-Enabled Rich Internet Applications 350


13.1 Introduction 351
13.2 Traditional Web Applications vs. Ajax Applications 352
Contents xiii

13.3 Rich Internet Applications (RIAs) with Ajax 353


13.4 History of Ajax 355
13.5 “Raw” Ajax Example Using the XMLHttpRequest Object 356
13.6 Using XML and the DOM 361
13.7 Creating a Full-Scale Ajax-Enabled Application 366
13.8 Dojo Toolkit 379
13.9 Web Resources 388

A XHTML Special Characters 389

B XHTML Colors 390

C JavaScript Operator Precedence Chart 393


C.1 Operator Precedence Chart 393

Index 395
This page intentionally left blank
Preface

… the challenges are for the designers of these applications: to forget what we think we know
about the limitations of the Web, and begin to imagine a wider, richer range of possibilities. It’s
going to be fun.
—Jesse James Garrett, Adaptive Path
“Ajax: A New Approach to Web Applications”
(adaptivepath.com/ideas/essays/archives/000385.php)

Introduction
Welcome to JavaScript for Programmers! We’ve worked hard to create what we hope you’ll
find to be an informative, entertaining and challenging learning experience. At Deitel & As-
sociates, we write programming language professional books and textbooks for Prentice
Hall, deliver corporate training at organizations worldwide and develop Internet businesses.
This book reflects the client side of today’s Web 2.0, Ajax-based, Rich Internet Appli-
cation-development methodologies. The technologies you’ll learn here are appropriate for
experienced professionals who build substantial web-based applications. You’ll find “indus-
trial-strength” code examples that are clear, straightforward and promote best practices.
Today’s users are accustomed to desktop applications with rich graphical user inter-
faces (GUIs), such as those used on Apple’s Mac OS X systems, Microsoft Windows sys-
tems, various Linux systems and others. Users want applications that can run on the
Internet and the web and communicate with other applications. Users want to apply data-
base technologies for storing and manipulating their business and personal data. They
want applications that are not limited to the desktop or even to some local computer net-
work, but that can integrate Internet and web components, and remote databases. Pro-
grammers want to use all these capabilities in a truly portable manner so that applications
will run without modification on a variety of platforms.
We focus on the client side of web-based applications (i.e., the portions that typically
run in web browsers such as Mozilla’s Firefox, Microsoft’s Internet Explorer, Apple’s
Safari, Opera, Google’s Chrome and other web browsers), using technologies such as
XHTML, JavaScript, CSS, Extensible Markup Language (XML) the DOM (Document
Object Model) and Ajax (Asynchronous JavaScript and XML).
This book was extracted from the front half our Prentice Hall textbook Internet &
World Wide Web How to Program, 4/e. That book also provides substantial treatments of
key Rich Internet Applications development server-side technologies, including web
servers, database, PHP, Ruby on Rails, ASP.NET/ASP.NET Ajax, JavaServer Faces and
web services.
Perhaps most important, this book presents over 100 working code examples and
shows the outputs produced when these examples are rendered in browsers. We present all
xvi Preface

concepts in the context of complete working programs. We call this the “live-code
approach.” All of the source code is available for download from
www.deitel.com/books/jsfp/

Please see the Before You Begin section following the Preface for details on downloading
these examples.
If you have questions as you read this book, send an e-mail to deitel@deitel.com—
we’ll respond promptly. For updates on the book and the status of all supporting software,
and for the latest news on Deitel publications and services, visit www.deitel.com. Sign up
at www.deitel.com/newsletter/subscribe.html for the free Deitel® Buzz Online e-mail
newsletter and check out www.deitel.com/ResourceCenters.html for our growing list of
Internet and web programming, Internet business, Web 2.0 and related Resource Centers.
Each week we announce our latest Resource Centers in the newsletter.

Key Features
Here’s some of the key features of JavaScript for Programmers:
• Reflects the client side of today’s Web 2.0, Ajax-based, Rich Internet Applica-
tion-development methodologies in which you create web applications with the
interactivity of desktop applications.
• Covers the two leading web browsers—Internet Explorer and Firefox. All client-
side applications in the book run correctly on both browsers.
• Focuses on Web 2.0 technologies and concepts.
• Chapter on building Ajax-enabled web applications with “raw” Ajax and with the
Dojo JavaScript libraries. Applications in this chapter demonstrate core Web 2.0
capabilities—partial-page updates and type-ahead.
• Significant treatment of client-side scripting with JavaScript.
• Significant treatments of XHTML DOM manipulation and JavaScript events.
• Significant treatment of XML DOM manipulation with JavaScript.
• Client-side case studies that enable you to interact with preimplemented server-
side applications and web services that we host at test.deitel.com.
• Case studies including Deitel Cover Viewer (JavaScript/DOM), Address Book
(Ajax) and Calendar (Ajax with the Dojo Toolkit).
All of this has been carefully reviewed distinguished industry developers and academics.

JavaScript for Programmers Achitecture


Figure 1 shows the architecture of JavaScript for Programmers. The book is divided into
five parts. The first part, Chapter 1, introduces the Internet, the web and Web 2.0.
The second part, Chapters 2–3, focuses on the markup (XHTML) and presentation
(CSS) technologies that enable you to build web pages. You’ll want to test your web appli-
cations across many browsers and platforms. The examples for the book execute correctly
on both Microsoft’s Internet Explorer 7 and Mozilla’s Firefox 3 browsers. Most of the
examples will also work in other browsers such as Opera, Apple’s Safari and Google’s
Teaching Approach xvii

Markup Intro
1. Introduction

2. Introduction to XHTML
3. Cascading Style Sheets™ (CSS)

4. JavaScript: Introduction to Scripting


5. JavaScript: Control Statements 1
JavaScript 6. JavaScript: Control Statements 2
7. JavaScript: Functions
8. JavaScript: Arrays
9. JavaScript: Objects
10. DOM: Objects and Collections
11. JavaScript: Events
Ajax XML

12. XML and RSS

13. Ajax-Enabled Rich Internet Applications

Fig. 1 | Architecture of JavaScript for Programmers

Chrome, but may not work on earlier browsers. Microsoft Windows users of this book
should use Internet Explorer 7 or Firefox 3; readers who have other operating systems
should install Firefox 3. Firefox 2 will also work with this book.
The third part of the book, Chapters 4–11, presents an eight-chapter treatment of
JavaScript, including an introduction followed by control statements, functions, arrays
and objects. Chapter 10 focuses on the objects and collections that enable you to manip-
ulate web page elements from JavaScript. Chapter 11 demonstrates event handling in
JavaScript, which enables you to respond to user interaction with web page elements.
Chapters 4–11 depend on the XHTML and CSS concepts presented in Chapters 2–3.
The fourth part of the book, Chapter 12, presents XML and RSS—two technologies
used frequently in Web 2.0 applications to transmit data between servers and clients.
Finally, our presentation concludes with Chapter 13’s treatment of Ajax development.
Ajax is not a new technology—we’ve been writing about all but one of its component tech-
nologies since the first edition of our book Internet & World Wide Web How to Program in
1999, and many of the technologies existed before that. However, Ajax is one of the key
technologies of Web 2.0 and RIAs. The chapter starts with “raw” Ajax development then
discusses “encapsulated” Ajax development with the Dojo libraries. Chapters 12–13
depend on the concepts presented in Chapters 2–11.

Teaching Approach
JavaScript for Programmers contains a rich collection of examples. The book concentrates
on the principles of good software engineering and stresses program clarity. We are edu-
cators who teach leading-edge topics in industry classrooms worldwide. The Deitels have
taught courses at all levels to government, industry, military and academic clients of Deitel
& Associates, Inc.
xviii Preface

Live-Code Approach. JavaScript for Programmers is loaded with “live-code” examples—


each new concept is presented in the context of a complete working web application that
is immediately followed by one or more screen captures showing the application’s func-
tionality. This style exemplifies the way we teach and write about programming; we call
this the “live-code approach.”
Syntax Shading. We syntax shade all the code, similar to the way most integrated-devel-
opment environments and code editors syntax color code. This improves code readabili-
ty—an important goal, given that this book contains about 6,000 lines of code in
complete, working programs. Our syntax-shading conventions are as follows:
comments appear in italic
keywords appear in bold italic
errors appear in bold black
constants and literal values appear in bold gray
all other code appears in black

Code Highlighting. We place white rectangles around each program’s key code segments.
Using Fonts for Emphasis. We place the key terms and the index’s page reference for each
defining occurrence in bold italic text for easier reference. We emphasize on-screen com-
ponents in the bold Helvetica font (e.g., the File menu) and emphasize program text in the
Lucida font (e.g., int x = 5).

Web Access. All of the source-code examples for JavaScript for Programmers are available for
download from:
www.deitel.com/books/jsfp/

Site registration is quick, easy and free. Download all the examples, then run each program
in a browser as you read the corresponding text discussions. Making changes to the exam-
ples and seeing the effects of those changes is a great way to enhance your Internet and web
programming learning experience.
Objectives. Each chapter begins with a statement of objectives. This lets you know what
to expect and gives you an opportunity to determine if you have met these goals after read-
ing the chapter.
Quotations. The objectives are followed by quotations. Some are humorous, some are
philosophical, others offer interesting insights. We hope that you enjoy relating the quo-
tations to the chapter material.
Outline. The chapter outline helps you approach the material in a top-down fashion, so
you can anticipate what is to come and set a comfortable learning pace.
Illustrations/Figures. Abundant charts, tables, line drawings, programs and program out-
put are included.
Programming Tips. We include programming tips to help you focus on important aspects
of program development. These tips and practices represent the best we have gleaned from
a combined seven decades of programming and teaching experience. One of our readers
told us that she feels this approach is like the highlighting of axioms, theorems and corol-
laries in mathematics books—it provides a basis on which to build good software.
Deitel® Buzz Online Free E-mail Newsletter xix

Good Programming Practices


Good Programming Practices call attention to techniques that will help you produce programs
that are clearer, more understandable and more maintainable.

Common Programming Errors


Pointing out these Common Programming Errors reduces the likelihood that you’ll make the
same mistakes.
Error-Prevention Tips
These tips contain suggestions for exposing bugs and removing them from your programs; many
describe techniques for preventing bugs in the first place.

Performance Tips
These tips highlight opportunities for making your programs run faster or minimizing the
amount of memory that they occupy.

Portability Tips
We include Portability Tips to help you write code that will run on a variety of platforms, and
to explain how to achieve a high degree of portability.

Software Engineering Observations


The Software Engineering Observations highlight architectural and design issues that affect
the construction of software systems, especially large-scale systems.
Thousands of Index Entries. We’ve included an extensive index which is especially useful
when you use the book as a reference.

Deitel® Buzz Online Free E-mail Newsletter


Each week, the free Deitel® Buzz Online newsletter announces our latest Resource Cen-
ter(s) and includes commentary on industry trends and developments, links to free articles
and resources from our published books and upcoming publications, product-release
schedules, errata, challenges, anecdotes, information on our corporate instructor-led train-
ing courses and more. It’s also a good way for you to keep posted about issues related to
JavaScript for Programmers. To subscribe, visit:
www.deitel.com/newsletter/subscribe.html

Deitel Online Resource Centers


Our website, www.deitel.com, provides scores of Resource Centers on various topics in-
cluding programming languages, software, Web 2.0, Internet business and open source
projects. You can view the complete list of Resource Centers in the first few pages of this
book or at www.deitel.com/ResourceCenters.html. These Resource Centers evolve out
of the research we do to support our books and business endeavors. We list many excep-
tional (mostly free) resources including tutorials, documentation, software downloads, ar-
ticles, blogs, podcasts, videos, code samples, books, e-books and more. We announce our
latest Resource Centers in the Deitel® Buzz Online.Acknowledgments
It is a great pleasure to acknowledge the efforts of many people whose names may not ap-
pear on the cover, but whose hard work, cooperation, friendship and understanding were
xx Preface

crucial to the production of the book. Many people at Deitel & Associates, Inc. devoted
long hours to this project—thanks especially to Abbey Deitel and Barbara Deitel.
We’d also like to thank the participants in our Honors Internship program who con-
tributed to this publication—Ilana Segall, a mathematical and computational science
major at Stanford University; Scott Wehrwein, a computer science major at Middlebury
College; and Mark Kagan, a computer science, economics and math major at Brandeis
University.
We are fortunate to have worked on this project with the talented and dedicated team
of publishing professionals at Prentice Hall. We appreciate the extraordinary efforts of
Mark Taub, Editor-in-Chief of Prentice Hall Professional; John Fuller, Managing Editor
of Prentice Hall Professional and Marcia Horton, Editorial Director of Prentice Hall’s
Engineering and Computer Science Division. Carole Snyder and Dolores Mars did a
remarkable job recruiting the book’s review team and managing the review process. Sandra
Schroeder and Chuti Prasertsith did a wonderful job designing the book’s cover. Bob
Engelhardt and Scott Disanno did a marvelous job managing the book’s production.
This book was adapted from our book Internet & World Wide Web How to Program,
4/e. We wish to acknowledge the efforts of our reviewers on that book who worked on the
corresponding chapters. Adhering to a tight time schedule, they scrutinized the text and
the programs, providing countless suggestions for improving the accuracy and complete-
ness of the presentation.

Reviewers
Umachitra Damodaran (Sun Microsystems), Vadiraj Deshpande (Sun Microsystems),
Molly E. Holtzschlag (W3C), Ralph Hooper (University of Alabama, Tuscaloosa), John-
vey Hwang (Splunk, Inc.), Eric Lawrence (Microsoft), Billy B. L. Lim (Illinois State Uni-
versity), Shobana Mahadevan (Sun Microsystems), Anand Narayanaswamy (Microsoft),
John Peterson (Insync and V.I.O., Inc.), Jennifer Powers (University of Albany), José An-
tonio González Seco (Parlamento de Andalucia), Dr. George Semeczko (Royal & SunAl-
liance Insurance Canada), Steven Shaffer (Penn State University), Karen Tegtmeyer
(Model Technologies, Inc.), Eric M. Wendelin (Auto-trol Technology Corporation), Ray-
mond F. Wisman (Indiana University) and Daniel Zappala (Brigham Young University).
We hope you enjoy this look at the exciting world of JavaScript-based, client-side web
applications development. As you read the book, we’d sincerely appreciate your com-
ments, criticisms, corrections and suggestions for improving the text. Please address all
correspondence to deitel@deitel.com. We’ll respond promptly, and post corrections
and clarifications at www.deitel.com/books/jsfp/. We hope you enjoy reading
JavaScript for Programmers as much as we enjoyed writing it!
Paul J. Deitel
Dr. Harvey M. Deitel
Maynard, Massachusetts

About the Authors


Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., has almost
three decades of experience in the computer field. Paul is a graduate of MIT’s Sloan School
of Management, where he studied Information Technology. Through Deitel & Associ-
About Deitel & Associates, Inc. xxi

ates, Inc., he has delivered web programming, Java, C#, Visual Basic, C++ and C courses
to industry clients, including Cisco, IBM, Sun Microsystems, Dell, Lucent Technologies,
Fidelity, NASA at the Kennedy Space Center, White Sands Missile Range, the National
Severe Storm Laboratory, Rogue Wave Software, Boeing, Stratus, Hyperion Software,
Adra Systems, Entergy, CableData Systems, Nortel Networks, Puma, iRobot, Invensys
and many more. He holds the Sun Certified Java Programmer and Java Developer certifi-
cations and has been designated by Sun Microsystems as a Java Champion. He has lec-
tured on Java and C++ for the Boston Chapter of the Association for Computing
Machinery. He and his father, Dr. Harvey M. Deitel, are the world’s best-selling program-
ming-language textbook authors.
Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates,
Inc., earned B.S. and M.S. degrees from MIT and a Ph.D. from Boston University. He
earned tenure and served as the Chairman of the Computer Science Department at Boston
College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. Harvey and
Paul are the co-authors of dozens of books and multimedia packages and they are writing
many more. The Deitels’ texts have earned international recognition with translations
published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chi-
nese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish. Dr. Deitel
has delivered hundreds of professional seminars to major corporations, academic institu-
tions, government organizations and the military.

About Deitel & Associates, Inc.


Deitel & Associates, Inc., is an internationally recognized corporate training and author-
ing organization specializing in computer programming languages, Internet and web soft-
ware technology, object technology education and Internet business development through
its Web 2.0 Internet Business Initiative. The company provides instructor-led courses on
major programming languages and platforms, such as C++, Java, C, C#, Visual C++, Vi-
sual Basic, XML, object technology and Internet and web programming. The founders of
Deitel & Associates, Inc. are Paul J. Deitel and Dr. Harvey M. Deitel. The company’s cli-
ents include many of the world’s largest companies, government agencies, branches of the
military, and academic institutions. Through its 32-year publishing partnership with
Prentice Hall, Deitel & Associates, Inc. publishes leading-edge programming professional
books, textbooks, interactive multimedia Cyber Classrooms and online and offline LiveLes-
sons video courses. Deitel & Associates, Inc., and the authors can be reached via e-mail at:
deitel@deitel.com

To learn more about Deitel & Associates, Inc., its publications and its worldwide
Dive Into® Series Corporate Training curriculum, visit:
www.deitel.com/training/

and subscribe to the free Deitel® Buzz Online e-mail newsletter at:
www.deitel.com/newsletter/subscribe.html

Check out the growing list of online Resource Centers at:


www.deitel.com/ResourceCenters.html
xxii Preface

Individuals wishing to purchase Deitel publications can do so through:


www.deitel.com/books/index.html

The publisher offers discounts on this book when ordered in quantity for bulk pur-
chases or special sales, which may include electronic versions and/or custom covers and
content particular to your business, training goals, marketing focus, and branding inter-
ests. For more information, please contact:
U. S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com

For sales outside the U. S., please contact:


International Sales
international@pearsoned.com

Visit the publisher at www.phptr.com.


Before You Begin

Please follow these instructions to download the book’s examples and ensure you have a
current web browser before you begin using this book.

Downloading the JavaScript for Programmers Source Code


The source code in JavaScript for Programmers can be downloaded as a ZIP archive file
from www.deitel.com/books/jsfp/. After you register and log in, click the link for the
examples under Download Code Examples and Other Premium Content for Registered Us-
ers. Extract the example files to your hard disk using a ZIP file extractor program, such as
WinZip (www.winzip.com). On Windows, we suggest that you extract the files to a folder
such as C:\jsfp_examples. On Mac OS X and Linux, we suggest that you extract the files
to a folder named jsfp_examples in your home folder.

Web Browsers Used in This Book


We’ve tested every example in this book using Mozilla’s Firefox 2 and 3, and Microsoft’s
Internet Explorer 7 web browsers. Before you begin, ensure that you have one or both of
these browsers installed on your computer. Internet Explorer 7 is available only for
Microsoft Windows operating systems. If you are a Windows user and do not have Inter-
net Explorer 7, you can download it from www.update.microsoft.com using Microsoft’s
Windows Update service. Firefox is available for most platforms. You can download Fire-
fox 3 from www.firefox.com.
Many of the book’s examples will not work in Internet Explorer 6. Though most or
all of the examples in this book might run on other recent web browsers, such as Opera
(www.opera.com), Apple’s Safari (www.apple.com/safari/) and Google’s Chrome
(www.google.com/chrome/), we haven’t tested the examples on these or any other
browsers.

You are now ready to begin reading JavaScript for Programmers. We hope you enjoy
the book! If you have any questions, please e-mail us at deitel@deitel.com. We’ll
respond promptly.
This page intentionally left blank
1
Introduction

The renaissance of interest in


the web that we call Web 2.0
has reached the mainstream.
—Tim O’Reilly

Billions of queries stream


OBJECTIVES
across the servers of these In this chapter you’ll learn:
Internet services—the
aggregate thoughtstream of ■ The evolution of the Internet and the World Wide Web.
humankind, online.
■ What Web 2.0 is and why it’s having such an impact
—John Battelle, The Search among Internet-based and traditional businesses.
■ What Rich Internet Applications (RIAs) are and the key
People are using the web to
build things they have not
software technologies used to build RIAs.
built or written or drawn or ■ How object technology is improving the software
communicated anywhere else. development process.
—Tim Berners-Lee
■ The importance of JavaScript as the universal client
scripting language.
Some people take what we
contribute and extend it and
contribute it back. That's
really the basic open source
success story.
—David Heinemeier Hansson,
interviewed by Chris Karr at
www.Chicagoist.com
2 Chapter 1 Introduction
Outline
1.1 Introduction
1.2 History of the Internet and World Wide Web
1.3 World Wide Web Consortium (W3C)
1.4 Web 2.0
1.5 Key Software Trend: Object Technology
1.6 JavaScript: Object-Based Scripting for the Web
1.7 Browser Portability
1.8 Web Resources

1.1 Introduction
Welcome to Internet and World Wide Web programming and Web 2.0! We’ve worked
hard to create what we hope you’ll find to be an informative, entertaining and challenging
learning experience. As you read this book, you may want to refer to
www.deitel.com/books/jsfp/

for updates and additional information.


The technologies you’ll learn in this book are appropriate for experienced profes-
sionals who build substantial information systems. You’ll find “industrial-strength” code
examples. We have attempted to write in a clear and straightforward manner using best
programming and documentation practices.
Perhaps most important, the book includes over 100 working code examples and
shows the outputs produced when these examples are rendered in browsers or run on com-
puters. We present all concepts in the context of complete working programs. We call this
the “live-code approach.” All of the source code is available for download from
www.deitel.com/books/jsfp/.
We present a carefully paced introduction to “client-side” web programming, using
the popular JavaScript language and the closely related technologies of XHTML (Exten-
sible HyperText Markup Language), CSS (Cascading Style Sheets) and the DOM (Doc-
ument Object Model). We often refer to “programming” as scripting—for reasons that
will soon become clear.
JavaScript is among today’s most popular software development languages for web-
based applications. In this book, we present a number of powerful software technologies
that will enable you to build such applications. We concentrate on using technologies such
as the Extensible HyperText Markup Language (XHTML), JavaScript, CSS, and Exten-
sible Markup Language (XML) to build the portions of web-based applications that reside
on the client side (i.e., the portions of applications that typically run in your web browsers
such as Mozilla’s Firefox, Microsoft’s Internet Explorer, Opera, Google’s Chrome or
Apple’s Safari). The server side of web-based applications typically runs on “heavy-duty”
computer systems on which organizations’ business-critical websites reside. By mastering
the technologies in this book, you’ll be able to build the client side of substantial web-
based, client/server, database-intensive, “multitier” applications. Our sister book, Internet
& World Wide Web How to Program, 4/e, contains both the client-side programming mate-
rial from JavaScript for Programmers, and also presents a variety of server-side program-
ming technologies.
1.2 History of the Internet and World Wide Web 3

To keep up to date with Internet and web programming developments, and the latest
information on JavaScript for Programmers at Deitel & Associates, please register for our
free e-mail newsletter, the Deitel® Buzz Online, at
www.deitel.com/newsletter/subscribe.html

Please check out our growing list of Internet and web programming, and Internet business
Resource Centers at
www.deitel.com/resourcecenters.html

Each week, we announce our latest Resource Centers in the newsletter. A list of Deitel Re-
source Centers at the time of this writing is located in the first few pages of the book. The
Resource Centers include links to, and descriptions of, key tutorials, demos, free software
tools, articles, e-books, white papers, videos, podcasts, blogs, RSS feeds and more that will
help you deepen your knowledge of most of the subjects we discuss in this book.
Errata and updates for the book are posted at
www.deitel.com/books/jsfp/

You’re embarking on a challenging and rewarding path. We hope that you’ll enjoy
JavaScript for Programmers. As you proceed, if you have any questions, send e-mail to
deitel@deitel.com

and we’ll respond promptly.

1.2 History of the Internet and World Wide Web


In the late 1960s, one of the authors (HMD) was a graduate student at MIT. His research
at MIT’s Project MAC (now the Laboratory for Computer Science—the home of the
World Wide Web Consortium) was funded by ARPA—the Advanced Research Projects
Agency of the Department of Defense. ARPA sponsored a conference at which several doz-
en ARPA-funded graduate students were brought together at the University of Illinois at
Urbana-Champaign to meet and share ideas. During this conference, ARPA rolled out the
blueprints for networking the main computer systems of about a dozen ARPA-funded uni-
versities and research institutions. They were to be connected with communications lines
operating at a then-stunning 56 Kbps (i.e., 56,000 bits per second)—this at a time when
most people (of the few who could) were connecting over telephone lines to computers at
a rate of 110 bits per second. There was great excitement at the conference. Researchers at
Harvard talked about communicating with the Univac 1108 “supercomputer” at the Uni-
versity of Utah to handle calculations related to their computer graphics research. Many
other intriguing possibilities were raised. Academic research was about to take a giant leap
forward. Shortly after this conference, ARPA proceeded to implement the ARPANET,
which eventually evolved into today’s Internet.

Communicating Quickly and Easily


Things worked out differently from what was originally planned. Rather than enabling re-
searchers to share each other’s computers, it rapidly became clear that enabling researchers
to communicate quickly and easily via what became known as electronic mail (e-mail, for
4 Chapter 1 Introduction

short) was the key early benefit of the ARPANET. This is true even today on the Internet,
as e-mail and instant messaging facilitates communications of all kinds among more than
a billion people worldwide.

Mutiple Users Sending and Receiving Information Simultaneously


One of the primary goals for ARPANET was to allow multiple users to send and receive
information simultaneously over the same communications paths (e.g., phone lines). The
network operated with a technique called packet switching, in which digital data was sent
in small bundles called packets. The packets contained address, error-control and sequenc-
ing information. The address information allowed packets to be routed to their destina-
tions. The sequencing information helped in reassembling the packets—which, because of
complex routing mechanisms, could actually arrive out of order—into their original order
for presentation to the recipient. Packets from different senders were intermixed on the
same lines. This packet-switching technique greatly reduced transmission costs, as com-
pared with the cost of dedicated communications lines.
The network was designed to operate without centralized control. If a portion of the
network failed, the remaining working portions would still route packets from senders to
receivers over alternative paths for reliability.

Protocols for Communication


The protocol for communicating over the ARPANET became known as TCP—the
Transmission Control Protocol. TCP ensured that messages were properly routed from
sender to receiver and that they arrived intact.
As the Internet evolved, organizations worldwide implemented their own networks
for both intraorganization (i.e., within the organization) and interorganization (i.e.,
between organizations) communications. A wide variety of networking hardware and soft-
ware appeared. One challenge was to get these different networks to communicate. ARPA
accomplished this with the development of IP—the Internet Protocol—truly creating a
“network of networks,” the current architecture of the Internet. The combined set of pro-
tocols is now commonly called TCP/IP.

Commercial Internet Use


Initially, Internet use was limited to universities and research institutions; then the mili-
tary began using the Internet. Eventually, the government decided to allow access to the
Internet for commercial purposes. Initially, there was resentment in the research and mil-
itary communities—these groups were concerned that response times would become poor
as “the Net” became saturated with users.
In fact, the exact opposite has occurred. Businesses rapidly realized that they could
tune their operations and offer new and better services to their clients, so they started
spending vast amounts of money to develop and enhance the Internet. This generated
fierce competition among communications carriers and hardware and software suppliers
to meet this demand. The result is that bandwidth (i.e., the information-carrying capacity)
of the Internet has increased tremendously and costs have plummeted.

World Wide Web


The World Wide Web allows computer users to locate and view multimedia-based docu-
ments on almost any subject over the Internet. Though the Internet was developed de-
1.3 World Wide Web Consortium (W3C) 5

cades ago, the web is a relatively recent creation. In 1989, Tim Berners-Lee of CERN (the
European Organization for Nuclear Research) began to develop a technology for sharing
information via hyperlinked text documents. Berners-Lee called his invention the Hyper-
Text Markup Language (HTML). He also wrote communication protocols to form the
backbone of his new information system, which he called the World Wide Web. In par-
ticular, he wrote the Hypertext Transfer Protocol (HTTP)—a communications protocol
for sending information over the web. Web use exploded with the availability in 1993 of
the Mosaic browser, which featured a user-friendly graphical interface. Marc Andreessen,
whose team at NCSA (the University of Illinois’ National Center for Supercomputing Ap-
plications) developed Mosaic, went on to found Netscape®, the company that many peo-
ple credit with initiating the explosive Internet economy of the late 1990s. Netscape’s
version of the Mosaic browser has been evolved by the Mozilla Corporation into the enor-
mously popular open source Mozilla Firefox browser.

Making Our Work and Lives Easier


In the past, most computer applications ran on computers that were not connected to one
another, whereas today’s applications can be written to communicate among the world’s
computers. The Internet mixes computing and communications technologies. It makes
our work easier. It makes information instantly and conveniently accessible worldwide. It
enables individuals and small businesses to get worldwide exposure. It is changing the way
business is done. People can search for the best prices on virtually any product or service.
Special-interest communities can stay in touch with one another. Researchers can be made
instantly aware of the latest breakthroughs. The Internet and the web are surely among
humankind’s most profound creations.

1.3 World Wide Web Consortium (W3C)


In October 1994, Tim Berners-Lee founded an organization—called the World Wide
Web Consortium (W3C)—devoted to developing nonproprietary, interoperable technol-
ogies for the World Wide Web. One of the W3C’s primary goals is to make the web uni-
versally accessible—regardless of ability, language or culture. The W3C (www.w3.org)
provides extensive resources on Internet and web technologies.
The W3C is also a standardization organization. Web technologies standardized by
the W3C are called Recommendations. W3C Recommendations include the Extensible
HyperText Markup Language (XHTML), Cascading Style Sheets (CSS), HyperText
Markup Language (HTML—now considered a “legacy” technology) and the Extensible
Markup Language (XML). A recommendation is not an actual software product, but a
document that specifies a technology’s role, syntax rules and so forth.

1.4 Web 2.0


In 2003 there was a noticeable shift in how people and businesses were using the web and
developing web-based applications. The term Web 2.0 was coined by Dale Dougherty of
O’Reilly® Media1 in 2003 to describe this trend. Although it became a major media buzz-

1. O’Reilly, T. “What is Web 2.0: Design Patterns and Business Models for the Next Generation
of Software.” September 2005 <http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/
09/30/what-is-web-20.html?page=1>.
6 Chapter 1 Introduction

word, few people really know what Web 2.0 means. Generally, Web 2.0 companies use
the web as a platform to create collaborative, community-based sites (e.g., social network-
ing sites, blogs, wikis, etc.).

Web 1.0
Web 1.0 (the state of the web through the 1990s and early 2000s) was focused on a rela-
tively small number of companies and advertisers producing content for users to access
(some people called it the “brochure web”). Web 2.0 involves the user—not only is the
content often created by the users, but users help organize it, share it, remix it, critique it,
update it, etc. One way to look at Web 1.0 is as a lecture, a small number of professors
informing a large audience of students. In comparison, Web 2.0 is a conversation, with ev-
eryone having the opportunity to speak and share views.

Architecture of Participation
Web 2.0 is providing new opportunities and connecting people and content in unique
ways. Web 2.0 embraces an architecture of participation—a design that encourages user
interaction and community contributions. You, the user, are the most important aspect of
Web 2.0—so important, in fact, that in 2006, TIME Magazine’s “Person of the Year” was
“you.”2 The article recognized the social phenomenon of Web 2.0—the shift away from
a powerful few to an empowered many. Several popular blogs now compete with tradi-
tional media powerhouses, and many Web 2.0 companies are built almost entirely on user-
generated content. For websites like MySpace®, Facebook®, Flickr™, YouTube, eBay®
and Wikipedia®, users create the content, while the companies provide the platforms.
These companies trust their users—without such trust, users cannot make significant con-
tributions to the sites.

Collective Intelligence
The architecture of participation has influenced software development as well. Open
source software is available for anyone to use and modify with few or no restrictions. Using
collective intelligence—the concept that a large diverse group of people will create smart
ideas—communities collaborate to develop software that many people believe is better and
more robust than proprietary software. Rich Internet Applications (RIAs) are being devel-
oped using technologies (such as Ajax) that have the look and feel of desktop software, en-
hancing a user’s overall experience. Software as a Service (SaaS)—software that runs on a
server instead of a local computer—has also gained prominence because of sophisticated
new technologies and increased broadband Internet access.
Search engines, including Google™, Yahoo!®, MSN®, Ask™, and many more, have
become essential to sorting through the massive amount of content on the web. Social
bookmarking sites such as del.icio.us and Ma.gnolia allow users to share their favorite sites
with others. Social media sites such as Digg™, Spotplex™ and Netscape enable the com-
munity to decide which news articles are the most significant. The way we find the infor-
mation on these sites is also changing—people are tagging (i.e., labeling) web content by
subject or keyword in a way that helps anyone locate information more effectively.

2. Grossman, L. “TIME’s Person of the Year: You.” TIME, December 2006 <http://
www.time.com/time/magazine/article/0,9171,1569514,00.html>.
1.5 Key Software Trend: Object Technology 7

Web Services
Web services have emerged and, in the process, have inspired the creation of many Web
2.0 businesses. Web services allow you to incorporate functionality from existing applica-
tions and websites into your own web applications quickly and easily. For example, using
Amazon Web Services™, you can create a specialty bookstore to run your website and
earn revenues through the Amazon Associates Program; or, using Google™ Maps web ser-
vices with eBay web services, you can build location-based “mashup” applications to find
auction items in certain geographical areas. Web services, inexpensive computers, abun-
dant high-speed Internet access, open source software and many other elements have in-
spired new, exciting, lightweight business models that people can launch with only a
small investment. Some types of websites with rich and robust functionality that might
have required hundreds of thousands or even millions of dollars to build in the 1990s can
now be built for nominal amounts of money.

Semantic Web
In the future, we’ll see computers learn to understand the meaning of the data on the
web—the beginnings of the Semantic Web are already appearing. Continual improve-
ments in hardware, software and communications technologies will enable exciting new
types of applications.
See our Web 2.0 Resource Center at www.deitel.com/web2.0/ for more information
on the major characteristics and technologies of Web 2.0, key Web 2.0 companies and
Web 2.0 Internet business and monetization models. The Resource Center also includes
information on user-generated content, blogging, content networks, social networking,
location-based services and more. We have separate Resource Centers on many Web 2.0
concepts and technologies. You can view a list of our Resource Centers in the first few
pages of this book and at www.deitel.com/ResourceCenters.html.

1.5 Key Software Trend: Object Technology


One of the authors, HMD, remembers the great frustration felt in the 1960s by software
development organizations, especially those working on large-scale projects. During his
undergraduate years, he had the privilege of working summers at a leading computer ven-
dor on the teams developing timesharing, virtual-memory operating systems. This was a
great experience for a college student. But, in the summer of 1967, reality set in when the
company “decommitted” from producing as a commercial product the particular system
on which hundreds of people had been working for many years. It was difficult to get this
thing called software right—software is “complex stuff.”
Improvements to software technology did emerge, with the benefits of structured pro-
gramming and the related disciplines of structured systems analysis and design being real-
ized in the 1970s. Not until the technology of object-oriented programming became
widely used in the 1990s, though, did software developers feel they had the necessary tools
for making major strides in the software development process.
What are objects and why are they special? Actually, object technology is a packaging
scheme that helps us create meaningful software units. These can be large and are highly
focused on particular applications areas. There are date objects, time objects, paycheck
objects, invoice objects, audio objects, video objects, file objects, record objects and so on.
In fact, almost any noun can be reasonably represented as an object.
8 Chapter 1 Introduction

We live in a world of objects. Just look around you. There are cars, planes, people,
animals, buildings, traffic lights, elevators and the like. Before object-oriented languages
appeared, procedural programming languages (such as Fortran, COBOL, Pascal, BASIC
and C) were focused on actions (verbs) rather than on things or objects (nouns). Program-
mers living in a world of objects programmed primarily using verbs. This made it awkward
to write programs. Now, with the availability of popular object-oriented languages, such
as C++, Java, Visual Basic and C#, programmers continue to live in an object-oriented
world and can program in an object-oriented manner. This is a more natural process than
procedural programming and has resulted in significant productivity gains.
A key problem with procedural programming is that the program units do not effec-
tively mirror real-world entities, so these units are not particularly reusable. It’s not
unusual for programmers to “start fresh” on each new project and have to write similar
software “from scratch.” This wastes time and money, as people repeatedly “reinvent the
wheel.” With object technology, the software entities created (called classes), if properly
designed, tend to be reusable on future projects. Using libraries of reusable componentry
can greatly reduce effort required to implement certain kinds of systems (compared to the
effort that would be required to reinvent these capabilities on new projects).
Software Engineering Observation 1.1
Extensive class libraries of reusable software components are available on the Internet. Many of
these libraries are free.

Software Engineering Observation 1.2


Some organizations report that the key benefit object-oriented programming gives them is not
software that is reusable but, rather, software that is more understandable, better organized and
easier to maintain, modify and debug. This can be significant, because perhaps as much as 80
percent of software cost is associated not with the original efforts to develop the software, but with
the continued evolution and maintenance of that software throughout its lifetime.

1.6 JavaScript: Object-Based Scripting for the Web


JavaScript is a powerful object-based scripting language with strong support for proper
software engineering techniques. You’ll create and manipulate objects from the start in
JavaScript. JavaScript is available free in today’s popular web browsers.
You’ll see that JavaScript is a portable scripting language and that programs written
in JavaScript can run in many web browsers. Actually, portability is an elusive goal.
Portability Tip 1.1
\

Although it is easier to write portable programs in JavaScript than in many other programming
languages, differences among interpreters and browsers make portability difficult to achieve.
Simply writing programs in JavaScript does not guarantee portability. You’ll occasionally need
to research platform variations and write your code accordingly.

Portability Tip 1.2


When writing JavaScript programs, you need to deal directly with cross-browser portability is-
sues. Such issues are hidden by JavaScript libraries, such as Dojo (discussed in Chapter 13), Pro-
totype, Script.aculo.us and ASP.NET Ajax, which provide powerful, ready-to-use capabilities
that simplify JavaScript coding by making it cross-browser compatible.
1.7 Browser Portability 9

Error-Prevention Tip 1.1


Always test your JavaScript programs on all systems and in all web browsers for which they are
intended.
JavaScript was created by Netscape, which created the first widely successful web
browser. Both Netscape and Microsoft have been instrumental in standardizing JavaScript
through ECMA International (formerly the European Computer Manufacturers Associa-
tion) as ECMAScript. Adobe Flash uses another scripting language named ActionScript.
ActionScript and JavaScript are converging in the JavaScript standard’s next version
(JavaScript 2/ECMA Script version 4) currently under development. This will result in a
universal client scripting language, greatly simplifying web application development.

1.7 Browser Portability


Ensuring a consistent look and feel on client-side browsers is one of the great challenges
of developing web-based applications. Currently, a standard does not exist to which soft-
ware developers must adhere when creating web browsers. Although browsers share a com-
mon set of features, each browser might render pages differently. Browsers are available in
many versions and on many different platforms (Microsoft Windows, Apple Macintosh,
Linux, UNIX, etc.). Vendors add features to each new version that sometimes cause cross-
platform incompatibility issues. Clearly it is difficult to develop web pages that render cor-
rectly on all versions of all browsers. In this book we develop web applications that execute
on the Internet Explorer 7 and Firefox 2 (and higher) browsers. Most examples will oper-
ate correctly in other recent browsers such as Opera, Apple’s Safari and Google’s Chrome,
but we have not explicitly tested the applications on these other browsers.

Portability Tip 1.3


The web is populated with many different browsers, which makes it difficult for authors and
web application developers to create universal solutions. The W3C is working toward the goal
of a universal client-side platform.

1.8 Web Resources


www.deitel.com/
Check this site frequently for updates, corrections and additional resources for all Deitel & Associ-
ates, Inc., publications.
www.deitel.com/ResourceCenters.html
Check out the complete list of Deitel Resource Centers, including numerous programming, open
source, Web 2.0 and Internet business topics.
www.w3.org
The World Wide Web Consortium (W3C) website offers a comprehensive description of web tech-
nologies. For each Internet technology with which the W3C is involved, the site provides a descrip-
tion of the technology, its benefits to web designers, the history of the technology and the future
goals of the W3C in developing the technology.
www.deitel.com/Ajax/
www.deitel.com/XML/
www.deitel.com/XHTML/
www.deitel.com/CSS21/
www.deitel.com/Dojo/
2
Introduction to
XHTML
To read between the lines
was easier than to follow the
text.
—Henry James

OBJECTIVES High thoughts must have


In this chapter you’ll learn: high language.
—Aristophanes
■ Important components of XHTML documents.
■ To use XHTML to create web pages. Yea, from the table of my
■ To add images to web pages. memory
I’ll wipe away all trivial
■ To create and use hyperlinks to navigate web pages. fond records.
—William Shakespeare
■ To mark up lists of information.
■ To create tables with rows and columns of data and He had a wonderful talent
control table formatting. for packing thought close,
■ To create and use forms to get user input. and rendering it portable.
—Thomas Babington
■ To make web pages accessible to search engines using Macaulay
<meta> tags.
2.1 Introduction 11
Outline
2.1 Introduction
2.2 Editing XHTML
2.3 First XHTML Example
2.4 W3C XHTML Validation Service
2.5 Headings
2.6 Linking
2.7 Images
2.8 Special Characters and Horizontal Rules
2.9 Lists
2.10 Tables
2.11 Forms
2.12 Internal Linking
2.13 meta Elements
2.14 Web Resources

2.1 Introduction
Welcome to the world of opportunity created by the World Wide Web. The Internet is
almost four decades old, but it wasn’t until the web’s growth in popularity in the 1990s
and the recent start of the Web 2.0 era that the explosion of opportunity we are experienc-
ing began. Exciting new developments occur almost daily—the pace of innovation is un-
precedented. In this chapter, you’ll develop your own web pages. As the book proceeds,
you’ll create increasingly appealing and powerful web pages.
This chapter begins unlocking the power of web-based application development with
XHTML—the Extensible HyperText Markup Language. Later in the chapter, we intro-
duce more sophisticated XHTML techniques such as internal linking for easier page nav-
igation, forms for collecting information from a web-page visitor and tables, which are
particularly useful for structuring information from databases (i.e., software that stores
structured sets of data). In the next chapter, we discuss a technology called Cascading Style
Sheets™ (CSS), a technology that makes web pages more visually appealing.
Unlike procedural programming languages such as C, C++, or Java, XHTML is a
markup language that specifies the format of the text that is displayed in a web browser
such as Microsoft’s Internet Explorer or Mozilla Firefox.
One key issue when using XHTML is the separation of the presentation of a docu-
ment (i.e., the document’s appearance when rendered by a browser) from the structure of
the document’s information. XHTML is based on HTML (HyperText Markup Lan-
guage)—a legacy technology of the World Wide Web Consortium (W3C). In HTML, it
was common to specify both the document’s structure and its formatting. Formatting
might specify where the browser placed an element in a web page or the fonts and colors
used to display an element. The XHTML 1.0 Strict recommendation (the version of
XHTML that we use in this book) allows only a document’s structure to appear in a valid
XHTML document, and not its formatting. Normally, such formatting is specified with
Cascading Style Sheets (Chapter 3). All our examples in this chapter are based on the
XHTML 1.0 Strict Recommendation.
12 Chapter 2 Introduction to XHTML

2.2 Editing XHTML


In this chapter, we write XHTML in its source-code form. We create XHTML documents
by typing them in a text editor (e.g., Notepad, TextEdit, vi, emacs) and saving them with
either an .html or an .htm filename extension.

Good Programming Practice 2.1


Assign filenames to documents that describe their functionality. This practice can help you iden-
tify documents faster. It also helps people who want to link to a page, by giving them an easy-to-
remember name. For example, if you are writing an XHTML document that contains product
information, you might want to call it products.html.
Computers called web servers running specialized software store XHTML docu-
ments. Clients (e.g., web browsers) request specific resources such as the XHTML docu-
ments from web servers. For example, typing www.deitel.com/books/downloads.html
into a web browser’s address field requests downloads.html from the books directory on
the web server running at www.deitel.com. For now, we simply place the XHTML doc-
uments on our computer and render them by opening them locally with a web browser
such as Internet Explorer or Firefox.

2.3 First XHTML Example


This chapter presents XHTML markup and provides screen captures that show how a
browser renders (i.e., displays) the XHTML. You can download the examples from
www.deitel.com/books/jsfp/. Every XHTML document we show has line numbers for
your convenience—these line numbers are not part of the XHTML documents. As you
read this book, open each XHTML document in your web browser so you can view and
interact with it as it was originally intended.
Figure 2.1 is an XHTML document named main.html. This first example displays
the message “Welcome to XHTML!” in the browser. The key line in the program is line
13, which tells the browser to display “Welcome to XHTML!” Now let us consider each
line of the program.

1 <?xml version = "1.0" encoding = "utf-8"?>


2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <!-- Fig. 2.1: main.html -->
6 <!-- First XHTML example. -->
7 <html xmlns = "http://www.w3.org/1999/xhtml">
8 <head>
9 <title>Welcome</title>
10 </head>
11
12 <body>
13 <p>Welcome to XHTML!</p>
14 </body>
15 </html>

Fig. 2.1 | First XHTML example. (Part 1 of 2.)


2.3 First XHTML Example 13

Title bar shows


contents of title
element

Fig. 2.1 | First XHTML example. (Part 2 of 2.)

Lines 1–3 are required in XHTML documents to conform with proper XHTML
syntax. For now, copy and paste these lines into each XHTML document you create. The
meaning of these lines is discussed in detail in Chapter 12.
Lines 5–6 are XHTML comments. XHTML document creators insert comments to
improve markup readability and describe the content of a document. Comments also help
other people read and understand an XHTML document’s markup and content. Com-
ments do not cause the browser to perform any action when the user loads the XHTML
document into the web browser to view it. XHTML comments always start with <!-- and
end with -->. Each of our XHTML examples includes comments that specify the figure
number and filename and provide a brief description of the example’s purpose. Subse-
quent examples include comments in the markup, especially to highlight new features.
Good Programming Practice 2.2
Place comments throughout your markup. Comments help other programmers understand the
markup, assist in debugging and list useful information that you do not want the browser to ren-
der. Comments also help you understand your own markup when you revisit a document to mod-
ify or update it in the future.
XHTML markup contains text that represents the content of a document and ele-
ments that specify a document’s structure. Some important elements of an XHTML doc-
ument are the html element, the head element and the body element. The html element
encloses the head section (represented by the head element) and the body section (repre-
sented by the body element). The head section contains information about the XHTML
document, such as its title. The head section also can contain special document formatting
instructions called style sheets and client-side programs called scripts for creating dynamic
web pages. (We introduce style sheets in Chapter 3 and scripting with JavaScript in
Chapter 4.) The body section contains the page’s content that the browser displays when
the user visits the web page.
XHTML documents delimit an element with start and end tags. A start tag consists
of the element name in angle brackets (e.g., <html>). An end tag consists of the element
name preceded by a forward slash (/) in angle brackets (e.g., </html>). In this example,
lines 7 and 15 define the start and end of the html element. Note that the end tag in line
15 has the same name as the start tag, but is preceded by a / inside the angle brackets.
Many start tags have attributes that provide additional information about an element.
Browsers can use this additional information to determine how to process the element.
Each attribute has a name and a value separated by an equals sign (=). Line 7 specifies a
required attribute (xmlns) and value (http://www.w3.org/1999/xhtml) for the html ele-
14 Chapter 2 Introduction to XHTML

ment in an XHTML document. For now, simply copy and paste the html element start
tag in line 7 into your XHTML documents. We discuss the details of the xmlns attribute
in Chapter 12.

Common Programming Error 2.1


Not enclosing attribute values in either single or double quotes is a syntax error. However, some
web browsers may still render the element correctly.

Common Programming Error 2.2


Using uppercase letters in an XHTML element or attribute name is a syntax error. However,
some web browsers may still render the element correctly.
An XHTML document divides the html element into two sections—head and body.
Lines 8–10 define the page’s head section with a head element. Line 9 specifies a title
element. This is called a nested element because it is enclosed in the head element’s start
and end tags. The head element is also a nested element because it is enclosed in the html
element’s start and end tags. The title element describes the web page. Titles usually
appear in the title bar at the top of the browser window, in the browser tab that the page
is displayed on, and also as the text identifying a page when users add the page to their list
of Favorites or Bookmarks that enables them to return to their favorite sites. Search engines
(i.e., sites that allow users to search the web) also use the title for indexing purposes.

Good Programming Practice 2.3


Indenting nested elements emphasizes a document’s structure and promotes readability.

Common Programming Error 2.3


XHTML does not permit tags to overlap—a nested element’s end tag must appear in the docu-
ment before the enclosing element’s end tag. For example, the nested XHTML tags
<head><title>hello</head></title> cause a syntax error, because the enclosing head ele-
ment’s ending </head> tag appears before the nested title element’s ending </title> tag.

Good Programming Practice 2.4


Use a consistent title-naming convention for all pages on a site. For example, if a site is named
“Bailey’s Website,” then the title of the contact page might be “Bailey’s Website—Contact.”
This practice can help users better understand the website’s structure.
Line 12 begins the document’s body element. The body section of an XHTML doc-
ument specifies the document’s content, which may include text and elements.
Some elements, such as the paragraph element (denoted with <p> and </p>) in line
13, mark up text for display in a browser. All the text placed between the <p> and </p>
tags forms one paragraph. When the browser renders a paragraph, a blank line usually pre-
cedes and follows paragraph text.
This document ends with two end tags (lines 14–15). These tags close the body and
html elements, respectively. The </html> tag in an XHTML document informs the
browser that the XHTML markup is complete.
To open an XHTML example from this chapter, open the folder where you saved the
book’s examples, browse to the ch04 folder and double click the file to open it in your
2.4 W3C XHTML Validation Service 15

default web browser. At this point your browser window should appear similar to the
sample screen capture shown in Fig. 2.1. (Note that we resized the browser window to save
space in the book.)

2.4 W3C XHTML Validation Service


Programming web-based applications can be complex, and XHTML documents must be
written correctly to ensure that browsers process them properly. To promote correctly
written documents, the World Wide Web Consortium (W3C) provides a validation ser-
vice (validator.w3.org) for checking a document’s syntax. Documents can be validated
by providing a URL that specifies the file’s location, by uploading a file to valida-
tor.w3.org/file-upload.html or by pasting code directly into a text area. Uploading a
file copies the file from the user’s computer to another computer on the Internet. The
W3C’s web page indicates that the service name is MarkUp Validation Service and that the
validation service is able to validate the syntax of XHTML documents. All the XHTML
examples in this book have been validated successfully using validator.w3.org.
By clicking Choose…, users can select files on their own computers for upload. After
selecting a file, clicking the Check button uploads and validates the file. If a document con-
tains syntax errors, the validation service displays error messages describing the errors.

Error-Prevention Tip 2.1


Most current browsers attempt to render XHTML documents even if they are invalid. This often
leads to unexpected and possibly undesirable results. Use a validation service, such as the W3C
MarkUp Validation Service, to confirm that an XHTML document is syntactically correct.

2.5 Headings
Some text in an XHTML document may be more important than other text. For example,
the text in this section is considered more important than a footnote. XHTML provides
six headings, called heading elements, for specifying the relative importance of informa-
tion. Figure 2.2 demonstrates these elements (h1 through h6). Heading element h1 (line
13) is considered the most significant heading and is typically rendered in a larger font
than the other five headings (lines 14–18). Each successive heading element (i.e., h2, h3,
etc.) is typically rendered in a progressively smaller font.

Portability Tip 2.1


The text size used to display each heading element can vary significantly between browsers. In
Chapter 3, we discuss how to control the text size and other text properties.

Look-and-Feel Observation 2.1


Placing a heading at the top of every XHTML page helps viewers understand the purpose of each
page.

Look-and-Feel Observation 2.2


Use larger headings to emphasize more important sections of a web page.
16 Chapter 2 Introduction to XHTML

1 <?xml version = "1.0" encoding = "utf-8"?>


2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <!-- Fig. 2.2: heading.html -->
6 <!-- Heading elements h1 through h6. -->
7 <html xmlns = "http://www.w3.org/1999/xhtml">
8 <head>
9 <title>Headings</title>
10 </head>
11
12 <body>
13 <h1>Level 1 Heading</h1>
14 <h2>Level 2 heading</h2>
15 <h3>Level 3 heading</h3>
16 <h4>Level 4 heading</h4>
17 <h5>Level 5 heading</h5>
18 <h6>Level 6 heading</h6>
19 </body>
20 </html>

Fig. 2.2 | Heading elements h1 through h6.

2.6 Linking
One of the most important XHTML features is the hyperlink, which references (or links
to) other resources, such as XHTML documents and images. When a user clicks a hyper-
link, the browser tries to execute an action associated with it (e.g., navigate to a URL, open
an e-mail client, etc.). In XHTML, both text and images can act as hyperlinks. Web
browsers typically underline text hyperlinks and color their text blue by default, so that
users can distinguish hyperlinks from plain text. In Fig. 2.3, we create text hyperlinks to
four different websites.
Line 14 introduces the strong element, which indicates that its contents has high
importance. Browsers typically display such text in a bold font.
Links are created using the a (anchor) element. Line 17 defines a hyperlink to the
URL assigned to attribute href, which specifies the location of a linked resource, such as
2.6 Linking 17

1 <?xml version = "1.0" encoding = "utf-8"?>


2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <!-- Fig. 2.3: links.html -->
6 <!-- Linking to other web pages. -->
7 <html xmlns = "http://www.w3.org/1999/xhtml">
8 <head>
9 <title>Links</title>
10 </head>
11
12 <body>
13 <h1>Here are my favorite sites</h1>
14 <p><strong>Click a name to go to that page.</strong></p>
15
16 <!-- Create four text hyperlinks -->
17 <p><a href = "http://www.deitel.com">Deitel</a></p>
18 <p><a href = "http://www.prenhall.com">Prentice Hall</a></p>
19 <p><a href = "http://www.yahoo.com">Yahoo!</a></p>
20 <p><a href = "http://www.usatoday.com">USA Today</a></p>
21 </body>
22 </html>

Fig. 2.3 | Linking to other web pages.

a web page, a file or an e-mail address. This particular anchor element links the text Deitel
to a web page located at http://www.deitel.com. When a URL does not indicate a spe-
cific document on the website, the web server returns a default web page. This page is often
called index.html; however, most web servers can be configured to use any file as the
default web page for the site. If the web server cannot locate a requested document, it
returns an error indication to the web browser, and the browser displays a web page con-
taining an error message to the user.
18 Chapter 2 Introduction to XHTML

Hyperlinking to an E-Mail Address


Anchors can link to e-mail addresses using a mailto: URL. When someone clicks this type
of anchored link, most browsers launch the default e-mail program (e.g., Microsoft Out-
look or Mozilla Thunderbird) to enable the user to write an e-mail message to the linked
address. Figure 2.4 demonstrates this type of anchor. Lines 15–17 contain an e-mail link.
The form of an e-mail anchor is <a href = "mailto:emailAddress">…</a>. In this case,
we link to the e-mail address deitel@deitel.com.

1 <?xml version = "1.0" encoding = "utf-8"?>


2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <!-- Fig. 2.4: contact.html -->
6 <!-- Linking to an e-mail address. -->
7 <html xmlns = "http://www.w3.org/1999/xhtml">
8 <head>
9 <title>Contact Page</title>
10 </head>
11
12 <body>
13 <p>
14 My email address is
15 <a href = "mailto:deitel@deitel.com">
16 deitel@deitel.com
17 </a>
18 . Click the address and your default email client
19 will open an e-mail message and address it to me.
20 </p>
21 </body>
22 </html>

Fig. 2.4 | Linking to an e-mail address.


2.7 Images 19

2.7 Images
The examples discussed so far demonstrate how to mark up documents that contain only
text. However, most web pages contain both text and images. In fact, images are an equally
important, if not essential, part of web-page design. The three most popular image formats
used by web developers are Graphics Interchange Format (GIF), Joint Photographic Ex-
perts Group (JPEG) and Portable Network Graphics (PNG) images. Users can create im-
ages using specialized software, such as Adobe Photoshop Elements (www.adobe.com),
G.I.M.P. (http://www.gimp.org) and Inkscape (http://www.inkscape.org). Images
may also be acquired from various websites. Figure 2.5 demonstrates how to incorporate
images into web pages.
Lines 14–15 use an img element to insert an image in the document. The image file’s
location is specified with the img element’s src attribute. This image is located in the same
directory as the XHTML document, so only the image’s filename is required. Optional
attributes width and height specify the image’s width and height, respectively. You can

1 <?xml version = "1.0" encoding = "utf-8"?>


2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
5 <!-- Fig. 2.5: picture.html -->
6 <!-- Images in XHTML files. -->
7 <html xmlns = "http://www.w3.org/1999/xhtml">
8 <head>
9 <title>Images</title>
10 </head>
11
12 <body>
13 <p>
14 <img src = "cpphtp6.jpg" width = "92" height = "120"
15 alt = "C++ How to Program book cover" />
16 <img src = "jhtp.jpg" width = "92" height = "120"
17 alt = "Java How to Program book cover" />
18 </p>
19 </body>
20 </html>

Fig. 2.5 | Images in XHTML files.


20 Chapter 2 Introduction to XHTML

scale an image by increasing or decreasing the values of the image width and height attri-
butes. If these attributes are omitted, the browser uses the image’s actual width and height.
Images are measured in pixels (“picture elements”), which represent dots of color on the
screen. Any image-editing program will have a feature that displays the dimensions, in
pixels, of an image. The image in Fig. 2.5 is 92 pixels wide and 120 pixels high.

Good Programming Practice 2.5


Always include the width and the height of an image inside the <img> tag. When the browser
loads the XHTML file, it will know immediately from these attributes how much screen space
to provide for the image and will lay out the page properly, even before it downloads the image.

Performance Tip 2.1


Including the width and height attributes in an <img> tag can help the browser load and render
pages faster.

Common Programming Error 2.4


Entering new dimensions for an image that change its inherent width-to-height ratio distorts the
appearance of the image. For example, if your image is 200 pixels wide and 100 pixels high, you
should ensure that any new dimensions have a 2:1 width-to-height ratio.
Every img element in an XHTML document must have an alt attribute. If a browser
cannot render an image, the browser displays the alt attribute’s value. A browser may not
be able to render an image for several reasons. It may not support images—as is the case
with a text-based browser (i.e., a browser that can display only text)—or the client may
have disabled image viewing to reduce download time. Figure 2.5 shows Internet Explorer
7 rendering an X symbol and displaying the alt attribute’s value, signifying that the image
(jhtp.jpg) cannot be found.
The alt attribute helps you create accessible web pages for users with disabilities,
especially those with vision impairments who use text-based browsers. Specialized software
called a speech synthesizer can “speak” the alt attribute’s value so that a user with a visual
impairment knows what the browser is displaying.
Some XHTML elements (called empty elements) contain only attributes and do not
mark up text (i.e., text is not placed between the start and end tags). Empty elements (e.g.,
img) must be terminated, either by using the forward slash character (/) inside the closing
right angle bracket (>) of the start tag or by explicitly including the end tag. When using
the forward slash character, we add a space before it to improve readability (as shown at
the ends of lines 15 and 17). Rather than using the forward slash character, lines 16–17
could be written with a closing </img> tag as follows:
<img src = "jhtp.jpg" width = "92" height = "120"
alt = "Java How to Program book cover"></img>

Using Images as Hyperlinks


By using images as hyperlinks, web developers can create graphical web pages that link to
other resources. In Fig. 2.6, we create six different image hyperlinks.
Lines 14–17 create an image hyperlink by nesting an img element in an anchor (a)
element. The value of the img element’s src attribute value specifies that this image
(links.jpg) resides in a directory named buttons. The buttons directory and the
Other documents randomly have
different content
conquer Cilicia with ease during his captivity. But his brother Leon
and the army behaved themselves very valiantly; they pressed
Lampron so closely in the absence of the Baron, and defended their
own country so well, that they released Rouben and acknowledged
his supremacy. The inhabitants of Lampron gave themselves and
their treasure up to the Baron of Cilicia. On his return to his own
country Rouben was kind and humane to every one, and at his
death left the crown to Leon; he gave him many rules concerning
the government of the country, and committed to him his daughters,
with an injunction not to give them foreign husbands, that the
Armenians might not be governed by foreigners and harassed by a
tyrant. Rouben was buried in Trassarg. 1185

Leon was a valiant and learned prince; he enlarged his principality


and became the master of many provinces. A few days only after his
taking possession of the country, the descendants of Ismael, under
the command of one Roustam, advanced and came against Cilicia.
(48) Leon was not frightened, but confiding in 1186
God, who destroyed Sanacherib, he vanquished
with a few men the great army of the infidels. Roustam himself
being killed by St. George,(49a) the whole Hagarenian army then
fled and dispersed; the Armenians pursued them and enriched
themselves by the booty. The power of Leon thus increased, and
being confident in his strength, he chased the Tadjiks(49b) and
pursued the Turks; he conquered Isauria and came as far as
Iconium; he captured Heraclea,(50) and again gave it up for a large
ransom; he blockaded Cæsarea,(51) and had nearly taken it; he
made a treaty with the Sultan of Iconium, and received a large sum
of money from him; he surrounded Cilicia on every side with forts
and castles; he built a new church called Agner, and was exceedingly
generous to all monasteries erected by his ancestors; his bounty
extended itself even to the leprous; they being shunned by every
body and expelled from every place, he assigned to them a
particular house, and provided them with necessaries.
By such proceedings Leon attained a great name and became
known to the Emperor of the Franks and the Greeks, and both, by
Heavens’ grace, favoured him with the diadem; and, indeed, the
mission by which Leon the Great was crowned King,(52) was very
famous. The Armenians assembled together in Jan. 6, 1198
the city of Tarsus, and in the cathedral of that
town the Catholicos(53) anointed Leon, as it is the custom, king of
the house of Thorgoma,(54) to sit on the throne and flourish in
kindness; to glorify the church, and to govern well the country; to
collect together the dispersed people, and to renovate its power;
lastly, to fill the country with peace and to make it as happy as
paradise.
This great king brought the Prince of Antioch over to him, by
marrying to him his niece, the daughter of his brother. He then made
an inroad into the province of Arasu and conquered the place called
Balresay; by his excellent wisdom he also gained Lampron.
The great Sultan of Iconium Caicaiuss(55) 1201
marched from Camir against the king, and
besieged the fort Capan. The unruly Armenian troops attacked the
enemy without waiting for an order of the king, and being partly
killed and partly taken prisoners, the Turks pressed very hard the
fort Capan. Leon did not let his spirits droop by this defeat; he
collected what troops remained with him, and went plundering the
territories of the Sultan as far as Camir. He laid waste the Sultan’s
country, and returned with a large booty. Hearing this the Sultan
started from Cilicia to his own principality, and made peace with
Leon, on the condition that the booty should be restored.
Leon, having governed the country twelve years as Baron and
twenty-two as King, felt his end approaching, and appointed in an
assembly of the whole nobility of the kingdom, a certain baron
named Atan to be Regent(56) of the country and guardian of his
daughter. Leon died soon after and was buried in the church of
Agner; a part of his body was brought into the town of Sis, and a
church was built thereupon.
After the assassination of Atan, Constantine May 1, 1219
was appointed regent, when he gave the
daughter of the king and the heiress of the empire (the good and
chaste lady Isabella), in marriage to one of the family of the king,
the barons acknowledged him as their lawful sovereign, and swore
the oath of allegiance.(57) But there arose a 1220
disturbance in the country; one Rouben(58) came
from the Prince of Antioch, gained over many of the nobility and
aspired to the crown. He soon took possession of Tarsus and was
about to march against Sis; but Constantine met him near Tarsus
with a great army, and vanquished this enemy. Rouben and the chief
men of his party died in prison.
By this victory Constantine became more powerful, and governed
the country with a firm hand; he built churches and honoured the
clergy. At this time the patriarch was called John, the sixth since
Nerses, from whom, as we have said, we began our chronicle, and
think it therefore proper to mention these blessed persons.
After the death of Nerses, that is to say, after his migration from
one life to another, Gregorius, called Degha, or the child, was
anointed. He was a fine and strong man. After him Gregorius, called
Carawesh, or killed by the stone;—then Gregorius Abirad;—and at
last John, whom we have before mentioned.(59) Leon entered into a
dispute with John, and appointed David in his place. This man
governed the church for two years in an excellent manner: but after
this, the king being reconciled to John, elevated him again on his
seat. After this reconciliation king Leon fell sick and died, very much
lamented by the Armenians. The Lord 1223
Constantine succeeded him, who excelling in
kindness, betrothed the heiress of the empire, Isabella, before an
assembly of the whole nobility, to his son Hethum.(60)
Hethum was then anointed king of Armenia; he was crowned with
a golden crown, and held a golden consecrated sceptre in his hand,
with a globe mounted in gold; he was placed on a high golden
throne, and having these signs of royalty in his right hand, he
promised to deal justice to the people at large and protect the poor
from injustice. Hethum was an excellent and gracious king; fine and
handsome in body and soul; religious, kind, compassionate, upright,
bountiful, and generous. The lawful heiress of the empire, Isabella,
governed the country together with her husband, and led a pious,
religious life. She was blessed for her good deeds and exemplary life
by many children, the numerous offsprings of a famous race.(61)
The first was the pious Leon, who is now the anointed king, and
after him Thoros, the blessed, who died the death of a hero.(62)
Isabella brought also into the world five daughters and another son,
Rouben, who died young. The queen being near 1252
the end of her life, and staying in a place called
Ked, she heard a voice from heaven, crying aloud, “come my dove,
come my love, thy end is near.” She felt joyful on this happy vision,
imparted it to the bystanders, and died in the Lord; her body was
brought to the grave by a large assembly of the priesthood and laid
in consecrated earth.
After the death of the Queen, the King was much occupied in the
government of his country; for there arose an insolent people from
the north, called Tatars, and also called, after their country, Mugal or
Mogul,(63) who laid waste all the countries which fell into their
hands. The words of the prophet Jeremiah, that “the seething pot
will run over from the north,” have been found true a second time,
this being the case we must expect the same consequences. There
were four kings, each of whom was accompanied(64) by ten chiefs,
which is even now the case. These four kings met together with
their ten followers; one arose and spoke with a loud voice in this
high assembly, and he being foremost in power, was declared “The
son of God in heaven.”(65) To him went king 1254
Hethum,(66) and there remained four years.
Hethum had considerable trouble, but he obtained friendly words,
and a written treaty after the custom of the Tatars.(67) He then
came back with great honours and conquered many provinces; he
routed the armies of the Persians or Turks,(68) and took their
country; he won by force Carmania; and Sebehesny was taken out
of the hands of the Turks, whose splendour faded away.(69) God’s
will was changed, and he looked again on us with a benevolent eye;
the doors of heaven were opened to let through his kindness on
earth. The country was fruitful and happy like paradise, and every
man sat in peace, as it is said in the scriptures, under his own vine.
But the Armenians in Cilicia caused themselves, like in former times,
Sodom and Ghomora, by their intemperance and wickedness to be
very soon devoured by the wrathful fire(70) of heaven.
The proud slaves who governed Egypt took by 1265
force Damascus, very hard pressed the Sultan of
Berea or Aleppo, and conquered all the country called by the name
of Shem.(71) These slaves united themselves with all the other
Hagarenians, and it was as if the sand of the sea arose to grasp
swords and daggers, and to fight the battles of men; they went
against the Christians, like avengers sent from God. The sea-coast
(from Gaza to Cilicia) suffered in particular; all the forts were
destroyed. Antioch, the great Antioch, fell into their hands—they
burned the houses, and the inhabitants were carried away into
foreign countries.(72) Having taken possession of the before-
mentioned territories, they went against Cilicia, sent to Hethum and
demanded tribute of him.(73) The king collected his soldiery under
the command of his sons, and hurried himself away to the Moguls
for aid.(74) He had not yet returned, when the Hagarenians came
into the country; the army fled, but the princes remained. Thoros
was killed in battle, and Leon was carried away prisoner from his
country. This unfortunate country was destroyed 1266
by fire, and the inhabitants were put to the
sword; but the forts, having received private encouragement from
Leon, could not be taken by the enemy, who retreated from them
with shame. The famous church in Sis and the town itself was given
up to the flames, but the inhabitants had time to fly.
Having done whatever they chose, the enemy returned to his own
country in great triumph, and with a large booty. After their
departure Hethum returned at the head of a Mogulian army into his
own kingdom, and saw all the misfortunes which had befallen him
during his absence; he wept bitterly, but he did not despair, and
placed reliance on the mercy of God. His son, who had been carried
away a prisoner, being endowed with a courageous nature, did not
let his spirits droop or show any fear; on the contrary, he cheered
the captives and consoled every man; for some he provided food, for
others he paid their ransom and set them at liberty. The army
presented Leon to the Sultan, who continued in his own country, and
who, looking on Leon and hearing his wise speech, received him
graciously, and spoke very kindly to him. With the permission of the
Sultan, Leon went to Jerusalem to adore the holy cross, and to pray
for the remission of his sins. He then went back to Egypt, into that
prison where Joseph was in former times. The priests admonished
him to think only of God; moreover, he constantly read the
Scriptures and was always ways absorbed in prayer. Therefore God
looked upon him with compassion, and turned the heart of the
Sultan to pity.
Leon, when taken prisoner, was thirty years of age; remaining one
year and ten months in Egypt, he made a treaty with the Sultan,
which was ratified by King Hethum his father. This being done, Leon
was set at liberty with great demonstrations of honour. The whole
country rejoiced when Leon returned to his father: crowds of people
ran to meet and see him; he embraced them all, and received them
with heavenly kindness. The king went, on foot, to thank God that
he had lived so long as to see his son Leon again, and in the
presence of the highly-gifted patriarch Jacobus, 1268
(75) the follower of Constantine, he earnestly
entreated Leon to take on him the government of the country, and
to be anointed King of Cilicia; but Leon could not, by all his
entreaties, be moved to accept this offer; and Hethum was
compelled, therefore, to see his son only Baron of the Armenians,
until he could enjoy the kingdom. The king happened to fall sick at
this time and never recovered. There was consequently a great
consternation in the country, and the people united together to give
him the surname of Makar.(76) Having finished 1269
this mortal, and gained an immortal life, he was
buried in Trassarg, and was celebrated in a poem. The Baron Leon
was so afflicted by the death of his father, that he fell into a mortal
sickness, and although all men supplicated him to be speedily
crowned King of Cilicia, he would not do it instantly, but mourned
three months. The neighbouring sovereigns, the Sultan of Egypt, the
Khan, and other princes, sent missions of peace to him, entreating
that he might be crowned King of Cilicia. Moved and encouraged by
these messages, he called a great assembly of Armenians to Tarsus
with the patriarch to anoint him, and to fulfil the duties of the
church. Leon received the sceptre with the golden globe in his right
hand,—and the Holy Ghost descended on him,—to be king on the
house of Thorgoma; to govern and to defend the flock after the law
of God.
Leon, sitting on the throne of his forefathers, was gracious to
every body; he pardoned those who had offended him, and was in
general exceedingly humane; he augmented the officers of the royal
household, and held the clergy in high esteem. He provided for the
poor ecclesiastics, and generally for all poor people; in what place
soever he stayed, the indigent were provided for from the court.
This being known, many people came from foreign parts, soldiers
and others, and remained months although not invited; their
expenses were payed by the court. Leon benefited the clergy even
more than his forefathers, and gave to the Vartabeds their proper
rank,(77) for he was a friend of learning;(78) every person who was
elevated to the dignity of a Vartabed received a present from the
king, and it was registered as an eternal remembrance. The army
received higher pay than before, and the king was so kind to every
body, so generous, so compassionate,(79) that all were delighted;
and the whole nation of Armenians became, as it were, renovated.
Satan, the author of all mischief, saw this, and he contrived to fight
against the king; he tempted him by misfortunes like Job; he tried
him by many wounds, but the king was found of more patience than
even Job himself, for Job spoke of his temptations with his friends,
and uttered curses as the misfortunes came one after the other.
Leon soon gained information of the plots of 1273
the chieftains of his own family, but confiding in
God, he took away only their castles, and granted them their lives;
he left it to the Lord to reward them after their designs. Now the
Sultan of Egypt, breaking the treaty he made with 1274
King Hethum, came against this country; he did
not so much as give any notice of his design. United with the Arabs
and the Turcomans, the Sultan, without any one being aware of it,
made an inroad into Cilicia. These Turcomans were a long time since
in this country as shepherds; they here kept their winter quarters,
and knew therefore all the passes and defiles.(80) 1276
United with these people the Egyptians harassed
the country more than had ever been the case before; they
penetrated into the mountains, discovered the recesses of men and
beasts, and destroyed numbers; many were also killed who had
been found in the flat country. Only those who were in forts and
castles escaped, all the rest were taken. The country was
surrounded on all sides and given to the flames; the enemy took
Tarsus, burnt the beautiful and celebrated church of St. Joseph, and
plundered the town; having done all this mischief, they retired.
King Leon, full of courage, wished to try the chance of a battle,
but the barons left him and he had only a few soldiers; seeing the
desolation of the country, he was very sorrowful, but consoled every
body and encouraged the people by presents. Whilst he was
sustaining these trials without scarcely uttering a sigh, one of his
sons, of tender age, died, and he himself fell into a sickness from
which he could scarcely be saved. Whilst yet depressed by his
sufferings he lost a daughter, but through all this he became not
impatient, and uttered not an angry word; he placed his confidence
in God, and suffered his trials with calmness. But there remained yet
another trial for the country at large; the country was visited by a
heavy plague, of which many poor people died, so that the land
could not be cultivated, and there was in consequence a want of the
necessaries of life. The king did not let his spirits droop, he animated
everybody, and said in the words of Job, “The Lord gave, and the
Lord hath taken away, blessed be the name of the Lord! Naked came
we into the world, and naked do we leave it again.” In these days
the Lord began to look on us again with kindness 1276
from above, and the words of the prophet Hosea were fulfilled, “The
shadow of death fled from us miserable men;” the Lord became
reconciled to the harassed and desolated nation of Armenia. For the
beginning of better days we were indebted to the people, who made
war against the king. Having plundered our country, the Sultan
withdrew his army, but Leon then came forward, vanquished all his
opponents, took a great booty and returned joyful into his own
kingdom.(81) The Sultan of Egypt hearing this, sent a message to
Leon for peace and friendship. The news of these victories spread
very far, so that the Khan(82) heard of it, sent armour and weapons,
and admonished Leon to carry on the war.
The Turks, who reign in Camir (Iconium), wished at this time to
make a treaty with the Moguls to hurt us; they spoke in
consequence very badly of us, and induced the Khan by a sum of
money to make a treaty with them.(83) The Turks spoke then more
freely, and accused us publicly, but they were soon undeceived; for
as soon as the union was dissolved, the Moguls came and destroyed
them by the sword, sent presents to our king, and behaved in
general very kindly to him. By this behavior the king gained courage,
made an incursion into Turkestan,(84) took a large booty and
returned into his own country with great joy. The neighbouring kings
hearing this were much astonished, and longed to be at peace with
us. Leon forgot all the mischief they had done, and accepted with a
kind heart their offerings of friendship; for he was benevolent by
nature, and rejoiced in kind dealings; misfortune could not depress
him, and good fortune could not elevate him; he looked only on God
and to govern his country well.
Leon had three sons: Hethum, the first born, learned in the
Scripture and clever in every branch of science; the second is called
Thoros, and the third Sempad. The spouse of the king, the Queen
Ceran, is famous for her fidelity and benevolence. So is our king,
who by God’s decree is placed over the country; may the Lord yet
grant him a long and a peaceful reign.(85)
Now to the end of my work I will subjoin some observations. It
has been said before, that when the Tadjiks came into our country,
they burned the house of God;—that they took the crosses, the
Scriptures, and all other holy materials, into their abominable hands
and cast them into the fire with infamous jokes; and that they put
the priests to the sword, and tortured all Christians. When all these
misfortunes befell the country, some of the inhabitants bore them
patiently, though reluctantly; and others became furious and uttered
impious words, for they were blind in spirit and weak in faith. “Can
this be,” said they, “can this be a true judgment, by which we are
condemned? Are we the only sinners of all the inhabitants of the
world, that we alone should be ruined? or are the Tadjiks the men of
righteousness, by whose hands we are killed: those unbelievers,
soiled by every wicked deed?” But from this reasoning it would
follow, that those who fell under the hall by which Sampson buried
himself, were not killed by reason of their own sins; that the
Galileans, who were put to death by Pilate, fell not by reason of their
own wickedness, but by the judgment of the Lord! All who are not
penitent will suffer the same punishment, God chastens him whom
he loves.(86) To rest his hopes on God, and to be patient in
misfortune, is the best way to live in this world and in the next. May
Leon, King of the Armenians, the writer and the reader of this, be
judged worthy to enter into this eternal and immortal world. To the
praise and honour of the three persons and one God, now and for
ever, world without end.
NOTES.
Note (1), page 23.
This is the famous patriarch Nerses Clajensis in the twelfth
century, one of the best writers of the Armenian nation. Galanus (I.
239) is full of praise of him. “Nerses Clajensis,” says he, “orthodoxus
patriarcha, quem Armenia universa, ut sanctum illius ecclesiæ
patrem et doctorem agnoscit, ejusque commemorationem in Liturgia
et Menelogiis celebrat. Fuit poeta sacer, et hac quidem facultate
adeo insignis, ut celebrioribus, meo judicio, vel Græcis vel Latinis
poetis in suo cœquandus sit idiomate.” But both the praises and the
censures of Galanus are to be received with great caution; he is
blinded by his orthodoxy, and praises and blames the authors not
according to their merit, but according to their faith. Nerses has
written much and on very different subjects; his elegy on the
capture of Edessa (1144) by the Turks, and his correspondence with
the emperor Alexius and Manuel, are the most interesting works for
us and for history. The elegy of Edessa has been printed several
times and in many places: most recently (1826) in Paris, but without
a French translation. The Archbishop Somal is not well-informed,
when he says, (Quadro della storia letteraria di Armenia. Venezia
1829, p. 84), “fu accompagnata da una versione francese.” The
correspondence of Nerses has only, as far as I know, been once
printed, viz. at St. Petersburgh, 1788, 1 vol. 4to. His short and
uninteresting chronicle of the History of Armenia has been often
printed, and for the last time in 1824 in Constantinople. The
Archbishop Somal says, that this work was corrupted by the
interpolations of the schismatical editor (“audacemente dall’editore
falsificata e con riprovevole temerita sparsa di alcune aggiunte
erronee contro il Concilio ecumenico di Calcedonia.”) It is strange
that the Armenians, who entertain the tenets of their national
church, and are styled schismatical by the proselytes of the Roman
Catholic Church, accuse the orthodox editors at Venice of the same
falsifications; the Armenians in India wish therefore to print all their
works, particularly the religious ones, at the press of the Bishop’s
College in Calcutta. (See Bishop Heber’s Journals, iii. 435. 3d
edition.)

Note (2), page 23.


This is king Leon III, who reigned from 1269 to 1289, and of
whom the chronicler speaks at the end of his work.

Note (3), page 23.


I imagine Vahram never read Lucretius: that author gives the
same reason for writing De Rerum Natura in verse.

Note (4), page 24.


Epist. ad Rom., chap. xiii. in the beginning.

Note (5), page 24.


The reader may recollect the old Byzantine pictures, painted on a
gold ground; there is a large collection of these pictures at
Schleisheim, near Munich.

Note (6), page 25.


I feel regret for poor Vahram, who here shows himself a heretic;
for notwithstanding that it was forbidden to add any article to the
creed of Nice, or rather Constantinople, the Latins added the
celebrated filioque, that is to say, that the Holy Ghost proceeded
from the Father and the Son, and condemned all others as heretics
who upheld the old church, and would not acknowledge these
innovations. Vahram, the Raboun, or doctor, shows himself to be
such a heretic. He even wrote some dissertations on the trinity and
the incarnation, at the command of his master king Leon III, but
they were never printed. The Roman Catholic author of the “Quadro
della letteratura di Armenia” (p. 115), says, that even in these works
Vahram “si prova scrittore di poco sana dottrina intorno al dogma
della processione dello Spirito-Santo.”

Note (7), page 25.


This is the language of all divines, and of those philosophers who
think whatever is, is right. If the sins of mankind have produced
Mahomed, why has Spain alone out of the nations of Europe been
depressed? Were these Visigoths greater sinners than their brethren
in the south of France or the Franks themselves? It is not a
speculative opinion, but the truth of history, that man is the architect
of his own fortune, and that the world belongs to the mighty.

Note (8), page 25.


The Turks were known in Europe as early as the beginning of the
sixth century of our era, but the western writers tell us nothing
satisfactory, either as to the name or the origin of this large division
of the human race. The Chinese, who were earlier acquainted with
their Thoo kiouei, are also contradictory in their statements. They
say, the Thoo kiouei are a particular tribe or class of the Hioung noo,
called by different names, and that they are called Thoo kiouei
because their town near the Altai, or gold mountain, had the form of
a helmet, and a helmet is called Thoo kiouei, yn y wei haou.
Matuanlin, in his great work, B. 343, initio, says this is the cause why
this people is so called. It is fortunate for historical literature, that
this accomplished Chinese scholar had no system in view in
compiling his work: he quotes on the same page other accounts on
the origin of the name Thoo kiouei and different traditions of the
original history of this nation. It has been remarked by Klaproth
(Asia Polyglotta, 212) that Thoo kiouei (or a very similar word)
means, indeed, in the Turkish language a helmet. If the Hiong noo
are Turks they cannot certainly be either the Huns of Attila or Fins.
Concerning the tribes of the Turks nothing is known with any
certainty; tribes rise and decay in Tartary like the sand-hills in the
desert: who can count them? The reader may find a lively and true
picture of this rising and falling of the different Turkoman tribes in a
novel, by Frazer, called Memoirs of a Kusilbash, printed 1828, in
three volumes. The different denomination of the same people,
Turks and Turkomans, is already used by William of Tyre, the
celebrated historian of the Crusades; it may be said that they differ
one from another, like, in former times, the Highlanders and
Lowlanders in Scotland. While describing the difference between
Turks and Turkomans, we may use the words of Dr. Robertson,
mentioning the attempt of King James II. to civilize the Highlands
and Isles. That great historian has the following words:—“The
inhabitants of the low country began gradually to forget the use of
arms, and to become attentive to the arts of peace. But the
Highlanders, or the Turkomans, retaining their natural fierceness,
averse from labour and inured to rapine, infested their more
industrious neighbours by their continual incursions.” (History of
Scotland, ad a. 1602.) Some modern authors think it worth their
while to take notice of a fault of a copyist (τοῦρκοι for ἰυρκαὶ), and
find therefore the Turks as early as in Herodotus, Pomponius Mela,
and Plinius; but this is not so unfair as to make Laura, the beautiful
and chaste Laura, responsible for eleven children, upon the faith of a
misinterpreted abbreviation, and the decision of a librarian. (Lord
Byron’s Notes on Childe Harold, Canto iv. stanza 30, lines 8 and 9.)

Note (9), page 26.


The kings are the different Arabian chiefs who ruled independently
of the Caliph of Bagdad; the emperor is the Emperor of
Constantinople, or the Roman emperor, as Vahram says, with the
other authors of these times. (See Gibbon, ch. 57.)

Note (10), page 26.


“The captives of these Turks were compelled to promise a spiritual
as well as temporal obedience; and instead of their collars and
bracelets, an iron horseshoe, a badge of ignominy, was imposed on
the infidels, who still adhered to the worship of their fathers.”
(Gibbon, l. c.)

Note (11), page 26.


This is not quite true; the Caliph of Bagdad,—which new town our
author calls in his poetical style by the ancient name of Babylon,—
could not move from his capital without the consent of the
descendents of Seljuk, but they never chose Babylon as the seat of
their empire; they had no metropolis, but they preferred Nishapur.
Abul Fazel (Ayeen Akbery II. 337) places Bagdad 33, and Babylon
32° 15´ latitude; their longitude is the same; 80° 55´ from the
Canary Islands.

Note (12), page 26.


The myriads of Turkish horse overspread a frontier of six hundred
miles from Tauris to Arzearum, and the blood of one hundred and
thirty thousand Christians was a grateful sacrifice to the Arabian
prophet. (Gibbon l. c.)

Note (13), page 26.


This is certainly the truth; the Armenians fled in their despair from
the new Mahometan to the old Christian enemy. It can be only
national vanity or folly, to assert or suppose that the Emperor
Michael would give the province of Cappadocia for a country
trampled on by the Seljuks, under whose irresistible power he felt
himself. The Cappadocians remembering how they were dealt with in
former time by the Armenians, and in particular by Tigranes, could
not receive their new guests with much pleasure; and this is the
principal reason of the great disaster which soon followed.
Διέθηκε δὲ φαύλως αὐτοὺς Τιγράνης ὁ Ἀρμένιος, ἡνίκα τὴν
καππαδοκίαν κατέδραμεν ἅπαντας γὰρ ἀναςάτους ἐποίησεν εἰς τὴν
Μεσοποταμίαν, &c. (Strabo xii. 2, vol. iii. 2d ed. Tauchn.) It is stated
by the American missionaries, who have visited Cappadocia, that
about 35,000 Armenians are still living in this province. “Cappadocia
has 30,000 Greeks and 35,000 Armenians.” (Mr. Gridley, in the
Missionary Herald, vol. xxiv, printed at Boston, p. 111.) Cæsarea has,
according to the same authority, from 60 to 80,000 inhabitants, and
of these 2,000 are Greeks, and 8,000 Armenians. (Herald, 260.)

Note (14), page 27.


The origin of this name of the people is not known. The
Armenians call themselves after their fabulous progenitor Haig, and
derive the name Armen from the son of Haig, Armenag; but I have
not much confidence in these ancient traditions of Moses of
Chorene. The Armenians are a strong instance that religion and
civilization only give a particular character and value to a people,
and preserve it from being lost in the course of time. Where are now
the thirty different nations, which Herodotus found (Melpom. 88),
between the bay of Margandius and the Triopian promontory? The
Armenians are certainly a tribe of the ancient Assyrians; their
language and history speak alike in favour of it. Nearly all the words
of Assyrian origin which occur in the Scriptures and in Herodotus can
be explained by the present Armenian language. Their traditions say,
also, that Haig came from Babylon; and Strabo’s authority would at
once settle the question, if he did not affirm too much. The Arabian
and the Syriac language, and consequently the people, are radically
different from the Armenian.
These are the passages of the geographer alluded to: Τὸ γὰρ τῶν
Ἀρμενίων ἔθνος καὶ τὸ τῶν Σύρων καὶ τῶν Ἀράβων, πολλὴν
ὁμοφυλίαν ἐμφαίνη κατὰ τε τὴν διάλεκτον ... καὶ οἱ Ἀσσύριοι, καὶ οἱ
Ἀριανοὶ, καὶ οἱ Ἀρμένιοι παραπλησίως τως ἔχουσι, καὶ πρὸς τούτους
καὶ πρὸς ἀλλήλους ... τοὺς ὑφ’ ἡμῶν Σύρους καλουμένους, ὑπ’
αὐτῶν τῶν Σύρον Ἀρμενίους καὶ Ἀραμμαίους καλεῖσθαι. (Strabo i. 2,
vol. i. 65, ed. Tauchn.) But the Aramæns or Syrians are quite a
different people from the Armenians, and Strabo is quite wrong
when he thinks that both names are commonly used to designate
one and the same nation. There is a fabulous story of a certain Er,
the son of a certain Armenios, a Pamphylian by birth (Plato de Rep.
x), but such stories are of no value in sober history.

Note (15), page 27.


This story is told with more details by some contemporary
chroniclers. Cakig reigned or rather had the name of a king from
1042-1079, and he is the last of the Bakratounian kings, a family
which began its reign under the supremacy of the Arabs in the year
859 of our era. As regards the geography, the reader may compare
the Mémoires sur l’Arménie, by Saint-Martin.

Note (16), page 27.


Armenia remained from the time of the Parthians a feudal
monarchy, and for this reason I use the expressions of the feudal
governments in the middle ages.

Note (17a), page 27.


Dionysius, in his description of the earth, says (v. 642) that the
mountain is called Taurus: οὕνεκα ταυροφανές τε καὶ ὀξυκάρηνον
ὁδεύει οὔρεσιν ἐκταδιόισι πολυσχεδὲς ἔνθα καὶ ἔνθα; perhaps more
poetical than true. “The road lies over the highest ridges of the
Taurus mountains, where, amidst the forests of pines, are several
beautiful valleys and small plains; there appears, however, no trace
of cultivation, though there is ample proof that these mountains
were anciently well inhabited, as we meet with scarcely a rock
remarkable for its form or position that is not pierced with ancient
catacombs.” (Col. Leake’s Asia Minor in Walpole’s Travels, i. 235.)

Note (17b), page 28.


This is the proper name for the possessions of Rouben; the
Armenians begin generally the line of the kings of Cilicia with the
flight of Rouben in 1080.

Note (18), page 28.


That is to say, as far as the gulph of Issus or Scanderum. Cilicia
and the sea-shore was also in former times once in the possession of
the kings of Armenia,—“the country on the other side of the Taurus,”
as the ancients used to say. Strabo says, from the Armenians (xiv. 5,
vol. iii. 321. ed. Tauchn.) that they, τὴν ἐκτὸς τοῦ Ταύρου
προσέλαβον μεχρὶ καὶ Φοινίκης. Plutarch says, that Tigranes “had
colonized Mesopotamia with Greeks, whom he drew in great
numbers out of Cilicia and Cappadocia.”—(Plutarch in Lucullo.)

Note (19), page 28.


Constantine sent many provisions to the Franks, when they were
besieging Antioch. The Armenians were happy to get such powerful
allies against their enemies, the Greeks. Alexius could not be very
well pleased with the creation of an Armenian Margrave by the
Latins, of whom he extorted “an oath of homage and fidelity, and a
solemn promise that they would either restore, or hold the Asiatic
conquests, as the humble and loyal vassals of the Roman empire”—
(Gibbon, iv., 131. London, 1826, published by Jones.) The Armenians
translate Margrave by Asbed, that is, Chief of the cavalry.

Note (20), page 29.


It is not easy to see what connexion there is between the
resurrection of a hen, or a duck, with the death of a king. What were
the principles of divination of these wise men, of whom Vahram
speaks?

Note (21), page 29.


The name of this fort is written differently by different authors; I
could not consult the great geographical works of Indjidjean.

Note (22), page 30.


I think that Trassarg and Trassag is the same word; the names of
places seem to be very corrupted in the Madras edition of Vahram’s
Chronicle. Chamchean says the king was buried in the monastery
Trassarg, which is very probable; but how could he say Thoros left
no son? In these monasteries the Armenian literature and sciences
in general were very much studied in the course of the eleventh and
twelfth centuries; some of the greatest Armenian authors flourished
in the time of the Crusades. In their libraries were collections of the
old classics, with many translations of the Greek authors; “e da
quest’ opere,” says the Archbishop Somal, “attinsero gli scrittori del
corrente secolo (the 12th), quello precisione d’idee, quella nobilita di
concetti, quella purezza di stile, per cui si rendettero veramente
gloriosi.” Quadro 80. Foreigners are at a loss to find all these good
qualities in the Armenian authors of the twelfth century.

Note (23), page 30.


With what caution the secretary of Leon III. relates the treachery
of Leon I. We see by this passage that Chamchean is in the wrong in
saying that Thoros left no son. (Epitome of the great history of
Armenia, printed in Armenian, at Venice in the year 1811, p. 300.)

Note (24), page 30.


Is not Mamestia the ancient Hamaxia? “Εἶθ Ἁμαξία ἐπὶ βουνοῦ
κατοικία τις,” says Strabo, ὕφορμον ἔχουσα, ὅπου κατάγεται ἡ
ναυπηγήσιμος ὕλη, (vol. iii. 221 ed. Tauchn.) It is certainly the
Malmestra of the Latins and Byzantines. This town is called
Mesuestra, Masifa, and by other names. (Wesseling Itner, p. 580.
See a note of Gibbon at the end of the 52d chapter.) Tarsus is very
well known as the principal town of Cilicia, as the native place of
many celebrated men, as the stoic Chrysippus, and of the Apostle
Paul. The following passage of Xenophon’s Expedition of Cyrus
illustrates very well the province and the whole history of the
Armenian kingdom of Cilicia. “Thence they prepared to penetrate
into Cilicia; the entrance was just broad enough for a chariot to
pass, very steep, and inaccessible to an army, if there had been any
opposition.... From thence they descended into a large and beautiful
plain, well watered and full of all sorts of trees and vines; abounding
in sesame, panic, millet, wheat and barley; and is surrounded with a
strong and high ridge of hills from sea to sea. After he had left the
mountains he advanced through the plain, and having made twenty-
five parasangas in four days’ march, arrived at Tarsus,” etc. (See
Spelman’s notes to his translation of the Expedition of Cyrus.) Tarsus
has now only, as it is said, 3,000 inhabitants.

Note (25), page 30.


The Armenian phrase has this double signification, and Leon
indeed carried on a war against the Seldjuks and the Count of
Antioch, who sought to deprive him by treachery of all his
possessions. Baldwin was not ashamed of doing any thing to enlarge
his dominions. I know not why Vahram speaks not a word about
these matters. (See Chamchean, l. c. p. 301.)

Note (26), page 30.


The old fabulous hero of Armenia, spoken of by Moses of Khorene.

Note (27), page 31.


Gibbon, iii. 341.

Note (28), page 31.


Joscelin I., Count of Edessa. (See the Digression on the Family of
Courtnay.—Gibbon, iv. 224.) Why does not Vahram, where he speaks
of the four sons of Leon, name this Stephanus, who lived in Edessa
with his uncle? It seems that there is a corruption in the text. Should
the name of Stephanus be hidden under Stephane, the crown of
Thoros, or which is more probable, is a line fallen out of our text? It
would be necessary to compare some manuscripts to restore the
original text. Thoros never received the kingly crown; he was only
Baron of Cilicia: Stephane seems, therefore, nothing else than
Stephanus.

Note (29), page 32.


This agrees with all that we know about the character of Calo-
Johanes. “Severe to himself, indulgent to others, chaste, frugal,
abstemious, the philosophic Marcus would not have disdained the
artless virtues of his successor, derived from his heart, and not
borrowed from the schools.”—(Gibbon.)

Note (30), page 32.


I am not able to look into the Byzantine version of this fact. Calo-
Johanes was not the man to be easily deceived, and to persecute
innocent persons; we know, on the contrary, that he pardoned many
people implicated in high treason. Calo-Johanes, as Camchean says
(l. c. 304), suspected also Leon and his other son Thoros, and they
were again sent to prison.

Note (31), page 34.


Our author has here the word Tadjik, a name by which he and the
other Armenian historians of the middle ages promiscuously call the
native Persians, the Gasnevides and the other Turks. The origin and
the proper meaning of this word will perhaps never be ascertained;
it has something of the vagueness of the ancient denomination of
Scythia and Scythians. It is certain that, in the works which go under
the name of Zoroaster, and in the Desatir, the Arabs are called Tazi,
and it is likewise certain that the language of this people, which is
now called Tadjik, is pure Persian; the Bochars are, in their own
country, called Tadjiks. How and why the ancient Persian name of
the Arabs should be given to the Persians themselves it is impossible
to conceive. Elphinstone (Account of the Kingdom of Câbul, London
1819, vol. i. 492) thinks that the Arabs and Persians were, in the
course of time, blended together into one nation, and became the
ancestors of the Tadjiks; but why should Armenians, Arabs, Turks
and Afghauns, call those mestizes with a name of the Pehlvi
language, which means originally an Arab? It seems rather that Tazi
and Tadjik are two different words; Tazi is the Persian name for
Arab, and Tadjik the name of a particular race of people, of whom
the Persians are only a tribe. I do not know on what authority
Meninski (see Klaproth’s Asia, Polygl. 243) relies, but it is certain that
the Chinese distinguish between the Ta she (Arabs) and the Ta yue
(the Tadjiks), of whom, as they say, the Po she (Persians) are only a
tribe. The Chinese had no communication with the Arabs before
Mahomed, but they heard of them by their intercourse with the
Sassanides, and call them, therefore by the Persian name Ta she
(9685, 9247), but the Po se (8605, 9669) are only, as they say, a
tribe like some other tribes, who formed particular kingdoms of the
Ta yue (9685, 12490), or Tadjiks. They have received the name Po
sse from their first king, Po sse na; but the Chinese had no direct
communication with Persia before Kobad or Cabades, Kiu ho to
(6063, 3984, 10260), as they spell the name, in their imperfect
idiom, who became known to them by his flight and misfortunes.
(See Matuanlin, l. c. Book 338, p. i, and following; Book 339, p. 6 a.,
p. 8 a., and the history of the Ta she or Arabs, p. 18, b. l. c.) But I
am in doubt of Matuanlin, who makes the Masdeizans, followers of
Buddha; he calls the Ateshgahs Fo sse (2539, 9659), Temples of
Buddha, (l. c. p. 6, b. l. 5.) The popular pronunciation of Ta yue is, in
many Chinese dialects, Tai yuet. I myself have often heard these
characters so pronounced in Canton, and it was then as nearly as
possible the ancient name of the Germans, Teut, the brethren of the
Persians; the Chinese know also that the Ye ta (12001, 9700),
Getae, Gothi, belong to the race of the Tayuet (Matuanlin, Book 338,
p. 11), &c. But what sober historian would draw conclusions from a
similarity of names? Perhaps a close inquiry may carry us to some
leading facts, by which we may be able to connect the information
of the east and the west. It would certainly be strange to begin the
history of the Germans with the extracts taken out of the Han and
Tang shoo. When I say the history of the Germans, I mean the
history of those remains of the Teuts who remained in Asia, for
Germany was certainly peopled long before the Chinese got any
information of the Ta yue. These races became only known in China
under the great dynasty of Han. A keen etymologist may, perhaps,
find the modern Tadjiks in the ancient Daai or Daae; he may
suppose that the Persians, like the Parthians, were only a branch of
the Scythians or Tatars, and with confidence adduce a passage of
Strabo, where it is said that the greater part of the Scythians are
known by the name of Daai, Οἱ μὲν δὴ πλείους τῶν Σκυθῶν Δάαι
προσαγορεύονται. (Strabo, Geogr. xi. 8, vol. ii. 430, ed. Tauchn.) I
will only add, that the same Strabo thinks, that the Daci (Δάκοι) may
in former times have been called Daï (Δάοι), but he distinguishes
them from the Daae (Δάαι). (Vol. ii. 36.)
Note (32), page 34.
Only the wounded pride of an Armenian could say this.

Note (33), page 34.


Have any of our modern travellers seen this monument? Claudian,
the famous Latin poet, had composed in Greek the Antiquity of
Tarsus, Anazarbus, Berytus, Nice, &c. Abul Fazel (Ayeen Akbery, ii.
348) places Tarsus long. 68° 40´, lat. 36° 50´. (See Note 24.)

Note (34), page 35.


The Armenians did so in imitation of the neighbouring Franks;
they took many customs from the Crusaders, and corrupted their
language by the introduction of many foreign words.

Note (35), page 35.


Is this surname of Manuel found in the Byzantine writers?

Note (36), page 36.


Vahram is in the wrong; Andronicus, not Manuel himself was at
the head of the army. (Chamchean, 306; Gibbon, iii. 344.) Thoros
was on such rocks, as Xenophon in the Anabasis, speaking of the
rocks of Cilicia, calls πέτρας ἠλιβάτους, “rocks inaccessible to every
thing but to the rays of the sun.” Homer makes often use of this
expression.

Note (37), page 36.


This is a very obscure passage in the original. Vahram is no friend
of details, and he is every moment in need of a rhyme for eal; who
can wonder, therefore, that he is sometimes obscure? This passage
is only clear, upon the supposition that Thoros divided the ransom
among his soldiers. This is also stated by Chamchean.
See Note 28.

Note (38), page 37.


I do not know why Vahram calls Thoros all on a sudden Arkay,
“king;” how the royal secretary exerts himself to draw a veil over the
treachery of Thoros!

Note (39), page 38.


Oscin is the father of a celebrated author and priest, Nerses
Lampronensis, so called from the town or fort Lampron; he was born
1153, and died 1198. In the concilium of Romcla 1179, Nerses spoke
for the union with the Latin church, and the speech he made on this
occasion is very much praised by the Armenians belonging to the
Roman Catholic Church. This speech has been printed at Venice with
an Italian translation, 1812. (Quadro 94.) Galanus, as the reader
may easily imagine, speaks in very high terms of Nerses (i. 325):
“Cujus egregia virtus,” says he, “digna plane est, ut acterna laude
illustretur, nomenque ad ultimas terrarum partes immortali fama
pervehatur.” For us his most interesting work is an elegy on the
death of his parent, master, and friend, Nerses Shnorhaly; he gives a
biography of this celebrated Catholicus, with many particulars of the
history of the time. Nerses Shnorhaly was not only an author and a
saint, but also a great statesman.

Note (40), page 38.


In the whole course of history the Armenian nobles shew a great
party feeling and much selfishness. They were never united for the
independence of their country; if one part was on the side of the
Persians or Turks, we shall certainly find another on the side of the
Greeks or Franks; and the native Armenian kings had more to fear
from their internal, than from their external enemies.

Note (41), page 38.


The history of the foundation of the Armenian kingdom in Cilicia is
very like the history of the rebellious Isaurians, “who disdained to be
the subjects of Galienus.” Thoros possessed a part of this savage
country; and we may say of him, what Gibbon said of the Isaurians:
“The most successful princes respected the strength of the
mountains and the despair of the natives.” (Gibbon, iii. 51.)

Note (42), page 38.


Iconium is mentioned as a station by Xenophon and Strabo; Cyrus
staid three days in “this last city of Phrygia.” St. Paul found there
many Jews and Gentiles; and it is said that even now, in its decayed
state, Conia or Iconium has 30,000 inhabitants. This town is above
300 miles from Constantinople. (Gibbon, iv. 152.) The chronology of
the Seljuks of Iconium may be seen in the Histoire des Huns, par
Deguignes. Kuniyah ‎‫‏قونيا‏‬‎is laid down by Abul Fazel (Ayeen Akbery, ii.
359), long. 66. 30., and lat. 41. 40. A description of the modern
Konia may be seen in Col. Leake’s Asia Minor, l. c. 223.

Note (43), page 40.


I find him not mentioned as an author in the “Quadro della storia
letteraria di Armenia.” It seems that his explanations of the prophets
are now lost. If the reader will compare the elogy of Thoros with the
facts in Vahram’s own chronicle, he will easily find that adulation,
and not truth, dictated it.

Note (44), page 40.


Seav or Sev-learn, Black-mountain (Karadagh). Here was a famous
monastery. Carmania is the place which formerly was called Laranda,
and this name is still, as Col. Leake remarks, in common use among
the Christians, and is even retained in the firmans of the Porte.
Caraman derives its name from the first and greatest of its princes,
who made himself master of Iconium, Cilicia, etc. (Col. Leake’s Asia
Minor, l. c. p. 232.)

Note (45), page 40.


An allusion to Ierem, i. 13.

Note (46), page 40.


It is known that the feudal laws and institutions have been
introduced into the possessions of the Franks in Asia. Baillis, or
Baillie, written Bail in the Armenian language, means a judge, and
the word is commonly found in this signification in the chronicles and
histories of the middle ages. The Baillis possessed powers somewhat
similar to those of the ancient Comites. We see here and in other
instances, that the Baillis are older than the end of the twelfth and
the beginning of the thirteenth century. At this time they began in
France. (Robertson, note 23, to his View of the State of Europe
before the History of the reign of the Emperor Charles V.)

Note (47), page 41.


It is very probable that the murderer Andronicus and Meleh were
acquainted with each other; their history and their crimes are
something similar.

Note (48), page 43.


Roustam was a Sultan of Iconium. (See the Chronology of these
Sultans in Deguigne’s Histoire des Huns.)

Note (49a), page 43.


In the times of the Crusades, wonders and witchcraft or
enchantment were daily occurrences; the Christians imputed all their
defeats to diabolical opposition, and their success to the assistance
of the military saints, Tasso’s celebrated poem gives a true picture of
the spirit of the times.

Note (49b), page 43.


Here the author uses again Tadjik as the name of a particular
people: but accuracy, I fear, is not the virtue of Vahram; he calls the
Turks of Iconium, the sons of Ismael or Hagar, i.e. Arabs.

Note (50), page 43.


Our author says not in what province these towns lay.
Chamchean, being able to consult other native historians, informs us
that Leon nearly took Cæsarea in Palestine.—Heraclea was perhaps
also the town of this name in Palestine; it was a small town near
Laodicæa in the time of Strabo. Τῇ Λαοδικεία πλησιάζει πολίχνια, τὸ,
τε Ποσείδιον καὶ Ἡράκλειον.—Strabo iii. 361, ed. Tauchn.

Note (51), page 43.


The old Samaria, called Cæsarea by Herodes, ἤν Ἡρώδης Σεβαςὴν
ἐπωνόμασεν, Strabo iii. 372. See the description of this famous place
in Carl Ritler’s Erdkunde ii. 393. Chamchean, 315. Abul Eazel (Ayeen
Akbery, ii. 337.) places it long. 66. 30. lat. 32. 50.

Note (52), page 44.


This memorable transaction is fully described in the great History
of Armenia by Chamchean, and in the work of Galanus, vol. i. p. 346
and following. Many letters of Leon and the Catholicos exist now
only in the Latin translations (Quadro l. c. 99.), or better have not
been heard of by the Mechitarists at Venice. Frederic I., to whom
Leon was very useful in the time of the second crusade, promised
the Baron of Cilicia to restore in his person the ancient kingdom of
Armenia. After the unfortunate death of the emperor, Leon sent
ambassadors to the Pope Celestinus III. and Henricus VI., to gratify
his wishes; the ambassadors came back to Cilicia in the society of
the archbishop Conrad of Mentz, bringing the crown from the
emperor and the benediction of the pope. The Emperor of
Constantinople, Alexius, sent also a crown to Leon “the Great.” The
king of Cilicia is, as far as I know, the only king who received the
crown by both the emperors of the west and the east, and by the
consent of the pope. The pope hoped to bring the Armenians under
his sway, and the Latins and the Greeks thought Leon a very useful
ally against the overpowering Saladin.—See the Letters in the
Appendix.

Note (53), page 44.


Catholicos of Armenia is the title of the Armenian patriarch.
Gregorius VI., called Abirad, was Catholicos at this time; he was
elected in the year 1195, and died 1203. The Latins had a very high
opinion of the power of an Armenian patriarch. Wilhelm of Tyrus,
speaking (De Bello Sacro, xvi. 18.) of the synod of Jerusalem in the
year 1141, has the following words: “Cui synodo interfuit maximus
Armeniorum pontifex, immo omnium episcoporum Cappadociæ,
Mediæ et Persidis et utriusque Armeniæ princips et doctor eximius
qui Catholicus dicitur.” Wilhelm might add, “et Indiæ,” for I think that
the Armenians, like the Syrians, formed as early as the sixth century
of our era, settlements in this part of the world. It is certain that
Armenians were in India as early as the year 800. (De Faria, in the
Collection of Voyages and Travels, by Kerr, Edinburgh 1812, vol. vi.
p. 419.)

Note (54), page 44.


The Armenians consider themselves the descendants of Thorgoma
(a name differently spelt in the different manuscripts and
translations of Genesis x. 3.) the son of Japet.

Note (55), page 44.


Vahram is too concise; he never gives the reasons of occurrences.
I see, in Chamchean, that Leon married, after the death of his first
wife, a daughter of Guido, king of Cyprus, by whom he had a
daughter, called Sabel or Elizabeth, his only child and heiress of the
kingdom. The Sultan of Ionium did not like these intimate
connexions of the Armenians with the Latins; he feared some
coalition against himself, and he thought it proper to be beforehand
with the enemy.

Note (56), page 45.


We have in the text again Bail or Bailly. I could not translate the
word otherwise than Regent: this is certainly the sense in which
Vahram uses this expression.

Note (57), page 46.


The name of this first husband of Isabella was Philippus, the son
of the Prince of Antioch and the niece of Leon. Philippus died very
soon, and Isabella, as our author says himself, married, 1223, the
son of the regent Constantine, Hethum or Haithon.

Note (58), page 46.


This Rouben was of the royal family.—Chamchean, 326.

Note (59), page 46.


It would carry us too far if we were to attempt to elucidate the
ecclesiastical history of these times, for there were many synods and
many negotiations between the Armenian clergy and the Greek and
Latin church, concerning the union. Pope Innocent III. showed also
at this opportunity his well-known activity. There exist many letters
from the Catholici and the Armenian kings to different popes and
emperors, with their answers,—ample matter for a diligent historian.
The first Gregorius after Nerses is Gregorius IV. from 1173-1193.
Gregorius V. from 1193-1195. Gregorius VI. from 1195-1202. John
VII. from 1202-1203. David III. from 1203-1205, and then again
John VII. 1205-1220. Constantine I. from 1220-1268. There were
yet two anti-Catholici, elected by a dissentient party, who are not
mentioned by Vahram.

Note (60), page 47.


The good Vahram seems to have forgotten what he said a short
time before. I do not know by what genealogy Chamchean could be
induced to say that Hethum is an offspring of Haig and the Parthian
kings.

Note (61), page 48.


The flattery of Vahram increases as he comes nearer to his own
time. I have sometimes taken the liberty to contract a little these
eulogies; the reader will certainly be thankful for it.

Note (62), page 48.


In the battle against the Mameluks of Egypt in the year 1266.

Note (63), page 48.


The Moguls are a branch, a tribe, or a clan of the Tatars; so say all
well-informed contemporary historians and chroniclers; so say in
particular the Chinese, who are the only sources for the early history
of the Turks, the Moguls, and Tunguses; nations which, in general,
from ignorance or levity, have been called Tatars—the Moguls only
are Tatars. The Armenians write the name Muchal; in our text of
Vahram, Muchan has been printed by mistake. That this people was
called so from their country is quite new; and if this were the case, it
would be still a question why the territory was called Mogul. There
are sometimes such whimsical reasons for the names of places and
nations, as to defy the strictest research and the greatest curiosity.
The name of Mogul seems not to be older than Tshinggis, and Mr.
Schmidt in St Petersburgh, derives the word from a Mongolian word,
which means keen, daring, valiant. The ancient name of the Moguls,
as it is given by the native historian Sätzan, is, I am afraid, only a
mistake of this ignorant chieftain. His whole history of the Moguls is
only a very inaccurate compilation from Chinese authors, and the
unlettered Mogul may have taken the appellative expression pih teih
8539, 10162, or pih too 10313, 8539, “northern barbarians” or
“northern country,” for the proper name of his forefathers. Long
before the Moguls, the Chinese became acquainted with some
barbarous tribes called by different names, and also Mo ho; but the
Chinese authors, who are so accurate in giving the different names
of one and the same people, never say that the Mung koo, who are
also written with quite different characters, are called Mo ho, or vice
versâ. These Mo ho are described as quite a distinct people, with a
particular language, divided into different clans or kingdoms. There
is an interesting description of this people under the name of Wŭh
keih 14803, 5918, in the Encyclopædia of Matuanlin, Book 326, p.
146. The same author says, in the sequel of his great work, that the
Kitans have nearly the same customs (sŭh 9545) as the Mo ho, but
he does not say that they are of the same race of people.—
Matuanlin, Book 345, in the beginning. The different names of the
Mo ho are also collected in Kanghi’s Dictionary under hŏ, a character
not to be found in Morrison’s Tonical Dictionary; it is composed out
of the rad. 177, and the sound giving group hŏ, 4019, and there also
exists no passage saying Mo ho and Mung koo are one and the same
people.

Note (64), page 49.


Vahram speaks of the four sons of Tshinggis. The army of the
Moguls and of Timur (see his Institutes, p. 229 foll.) was divided into
divisions of 10, 100, 1000, &c. The ten followers were the ten first
officers or “Comites,” as Tacitus calls the compeers of the German
princes. Similar customs are always found in a similar state of
society.

Note (65), page 49.


Vahram confounds probably the first election of the Emperor
Cublai, with the election of his follower Mangou, to whose residence
at Caracorum the King of Cilicia, Hethum, went as a petitioner.
Vahram knows that the title of the head of the Mongolian
confederacy is Teen tze, 10095, 11233, “the son of Heaven.” The
Mongolian emperors have only been called so, after the conquest of
China by Cublai. Teen tse is the common title of the Emperor of the
“Flowery empire.” According to other accounts, Tshinggis called
himself already “Son of Heaven.”
Note (66), page 49.
To Mangou khan; we know this by other contemporary historians.
There exist some Armenian historians in the 13th century, who
contain a good deal of information regarding the Moguls. One is
printed in the Mémoires sur l’Arménie, by Saint-Martin. See Quadro
della Storia, &c. p. 112, and following.

Note (67), page 49.


Is this treaty to be any where found? It would certainly be very
interesting. Vahram has the word kir, by which it is certain that
Hethum I. returned with a written treaty, which very probably was
written in the Mogulian language, and with the Mogulian characters.

Note (68), page 49.


Vahram has again the unsettled and vague name of Tadjik.

Note (69), page 49.


Vahram died before the beginning of the glory of Othman, and of
the increasing power of his descendants; he speaks of the fading
state of the Seljuks of Iconium.

Note (70), page 50.


I have taken the liberty to shorten a little the pious meditations of
our author; he would have done better to give us some details
regarding the interesting transactions with the Moguls.

Note (71), page 50.


Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like