96549

Download as pdf or txt
Download as pdf or txt
You are on page 1of 81

Download the full version of the ebook at

https://ebookultra.com

Learn JavaScript and Ajax with w3Schools 1st


Edition W3Schools

https://ebookultra.com/download/learn-javascript-
and-ajax-with-w3schools-1st-edition-w3schools/

Explore and download more ebook at https://ebookultra.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

AJAX Creating Web Pages with Asynchronous JavaScript and


XML 1st Edition Edmond Woychowsky

https://ebookultra.com/download/ajax-creating-web-pages-with-
asynchronous-javascript-and-xml-1st-edition-edmond-woychowsky/

ebookultra.com

Zk Ajax without Javascript Framework 1st Edition Henri


Chen

https://ebookultra.com/download/zk-ajax-without-javascript-
framework-1st-edition-henri-chen/

ebookultra.com

JavaScript Ajax for Dummies 1. Edition Andy Harris

https://ebookultra.com/download/javascript-ajax-for-dummies-1-edition-
andy-harris/

ebookultra.com

Practical JavaScript DOM Scripting and Ajax Projects 1st


Edition Frank Zammetti

https://ebookultra.com/download/practical-javascript-dom-scripting-
and-ajax-projects-1st-edition-frank-zammetti/

ebookultra.com
MooTools Essentials The Official MooTools Reference for
JavaScript and Ajax Development 1st Edition Aaron Newton

https://ebookultra.com/download/mootools-essentials-the-official-
mootools-reference-for-javascript-and-ajax-development-1st-edition-
aaron-newton/
ebookultra.com

Getting Started with Meteor js JavaScript Framework 2nd


Edition Learn to develop powerful web applications in
minutes with Meteor Isaac Strack
https://ebookultra.com/download/getting-started-with-meteor-js-
javascript-framework-2nd-edition-learn-to-develop-powerful-web-
applications-in-minutes-with-meteor-isaac-strack/
ebookultra.com

JavaScript with Promises 1st Edition Daniel Parker

https://ebookultra.com/download/javascript-with-promises-1st-edition-
daniel-parker/

ebookultra.com

Pro JavaScript with MooTools Learning Advanced JavaScript


Programming 1st Edition Mark Joseph Obcena (Auth.)

https://ebookultra.com/download/pro-javascript-with-mootools-learning-
advanced-javascript-programming-1st-edition-mark-joseph-obcena-auth/

ebookultra.com

Developing Responsive Web Applications with AJAX and


jQuery 1st Edition Sandeep Kumar Patel

https://ebookultra.com/download/developing-responsive-web-
applications-with-ajax-and-jquery-1st-edition-sandeep-kumar-patel/

ebookultra.com
Learn JavaScript and Ajax with w3Schools 1st Edition
W3Schools Digital Instant Download
Author(s): W3Schools
ISBN(s): 9780470611944, 0470611944
Edition: 1
File Details: PDF, 3.57 MB
Year: 2010
Language: english
Learn JavaScript and AJAX with w3schools
®

Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-61194-4
LOC/CIP: 2010925161
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any
form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise,
except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without
either the prior written permission of the Publisher, or authorization through payment of the appro-
priate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed
to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, N 07030,
(201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations
or warranties with respect to the accuracy or completeness of the contents of this work and spe-
cifically disclaim all warranties, including without limitation warranties of fitness for a particular
purpose. No warranty may be created or extended by sales or promotional materials. The advice
and strategies contained herein may not be suitable for every situation. This work is sold with the
understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should
be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The
fact that an organization or Website is referred to in this work as a citation and/or a potential source
of further information does not mean that the author or the publisher endorses the information the
organization or Website may provide or recommendations it may make. Further, readers should be
aware that Internet Websites listed in this work may have changed or disappeared between when this
work was written and when it is read.
For general information on our other products and services please contact our Customer Care
Department within the United States at (877) 762-2974, outside the United States at (317) 572-
3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, and related trade dress are trademarks or registered trade-
marks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries,
and may not be used without written permission. w3schools and the w3schools logo are registered
trademarks of w3schools. JavaScript is a registered trademark of Sun Microsystems, Inc. All other
trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with
any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print
may not be available in electronic books.
Library of Congress CIP Data is available from the publisher.
w3schools Authors/Editors
w3schools’ mission is to publish well-organized and easy-to-understand online tutorials
based on the W3C Web standards.
Hege Refsnes
Hege is a writer and editor for w3schools. She works to improve the usability and acces-
sibility of the Web.
Hege has been writing tutorials for w3schools since 1998.
Ståle Refsnes
Ståle has ten years of Internet development experience, developing all the Web-based solu-
tions for The Norwegian Handball Federation.
Ståle has been writing tutorials for w3schools since 1999.
Kai Jim Refsnes
Kai Jim has been around computers since childhood, working with them since the age
of 14.
He has been writing tutorials for w3schools since completing a bachelor’s degree in infor-
mation technology in 2005.
Jan Egil Refsnes
Jan Egil is the president and founder of w3schools.
He is a senior system developer with a master’s degree in information technology and
more than 30 years of computing experience.
“Jani” has supervised a large number of company-critical development projects for oil
companies like Amoco, British Petroleum, ELF, Halliburton, and Brown & Root. He has
also developed computer-based solutions for more than 20 governmental institutions like
The National Library, Norwegian High Schools, The State Hospital, and many others.
Jani started w3schools in 1998.
Credits
Acquisitions Editor Vice President and Executive Group
Scott Meyers Publisher
Richard Swadley
Production
Abshier House Vice President and Executive Publisher
Barry Pruett
Technical Editor
Harry Buss Associate Publisher
Jim Minatel
Copy Editor
Abshier House Project Coordinator, Cover
Lynsey Stanford
Associate Director of Marketing
David Mayhew Proofreading and Indexing
Abshier House
Production Manager
Tim Tate Cover Designer
Michael Trent
Table of Contents
Introduction..................................................1
JavaScript............................................................................................ 1
AJAX................................................................................................... 3
How To Use This Book....................................................................... 4

Section I: JavaScript Basic..............................7


Chapter 1: JavaScript How To and Where To............... 9
How To Put a JavaScript into an HTML Page..................................... 9
How to Handle Simple Browsers....................................................... 12
Where to Put the JavaScript.............................................................. 12
Using an External JavaScript............................................................. 15

Chapter 2: JavaScript Statements and Comments....... 16


JavaScript Statements........................................................................ 16
JavaScript Comments........................................................................ 18

Chapter 3: JavaScript Variables................................... 23


Do You Remember Algebra from School?.......................................... 23
JavaScript Variables........................................................................... 23
Declaring (Creating) JavaScript Variables.......................................... 25
Assigning Values to Undeclared JavaScript Variables.......................... 25
Redeclaring JavaScript Variables........................................................ 26
JavaScript Arithmetic........................................................................ 26

v
Table of Contents

Chapter 4: JavaScript Operators................................. 27


JavaScript Arithmetic Operators........................................................ 27
JavaScript Assignment Operators....................................................... 28
The + Operator Used on Strings........................................................ 28
Adding Strings and Numbers............................................................ 28

Chapter 5: JavaScript Comparisons............................ 30


Comparison Operators...................................................................... 30
How to Use Comparisons................................................................. 31
Logical Operators.............................................................................. 31
Conditional Operator....................................................................... 31

Chapter 6: JavaScript If...Else Statements................... 32


Conditional Statements..................................................................... 32
if Statement....................................................................................... 33
if...else Statement.............................................................................. 34
if...else if...else Statement................................................................... 36

Chapter 7: JavaScript Loops....................................... 39


The for Loop..................................................................................... 39
The while Loop................................................................................. 41
The do...while Loop.......................................................................... 43

Chapter 8: Additional JavaScript Flow Control


Statements.................................................................... 46
The break Statement......................................................................... 46
The continue Statement.................................................................... 47
JavaScript for...in Statement.............................................................. 48
JavaScript switch Statement............................................................... 50

vi
Table of Contents

Chapter 9: JavaScript Popup Boxes............................. 53


Popup Boxes...................................................................................... 53

Chapter 10: JavaScript Functions............................... 58


How to Define a Function................................................................ 58
JavaScript Function Examples........................................................... 59
The return Statement........................................................................ 62
The Lifetime of JavaScript Variables.................................................. 63

Chapter 11: JavaScript Events..................................... 64


onLoad and onUnload...................................................................... 64
onFocus, onBlur, and onChange....................................................... 65
onSubmit.......................................................................................... 65
onMouseOver and onMouseOut....................................................... 66
onClick............................................................................................. 66

Chapter 12: Javascript try…catch and


throw Statements.......................................................... 67
JavaScript—Catching Errors............................................................. 67
The try...catch Statement.................................................................. 67
The throw Statement......................................................................... 70

Chapter 13: JavaScript Special Characters and


Guidelines.................................................................... 73
Insert Special Characters................................................................... 73
JavaScript Is Case Sensitive................................................................ 74
White Space...................................................................................... 74
Break up a Code Line........................................................................ 74

vii
Table of Contents

Section II: JavaScript Objects.......................77


Chapter 14: JavaScript Objects Intro.......................... 79
Object-Oriented Programming......................................................... 79
Properties.......................................................................................... 79
Methods............................................................................................ 80

Chapter 15: JavaScript String Object.......................... 81


String Object..................................................................................... 81
Examples........................................................................................... 82

Chapter 16: JavaScript Date Object............................ 88


Create a Date Object......................................................................... 88
Set Dates........................................................................................... 89
Compare Two Dates.......................................................................... 89
Examples........................................................................................... 90

Chapter 17: JavaScript Array Object........................... 95


What Is an Array?.............................................................................. 95
Create an Array................................................................................. 96
Access an Array................................................................................. 96
Modify Values in an Array................................................................. 96
Examples........................................................................................... 97

Chapter 18: JavaScript Boolean Object.................... 107


Create a Boolean Object.................................................................. 107
Examples......................................................................................... 108

viii
Table of Contents

Chapter 19: JavaScript Math Object......................... 110


Math Object................................................................................... 110
Mathematical Constants.................................................................. 110
Mathematical Methods................................................................... 111
Examples......................................................................................... 112

Chapter 20: JavaScript RegExp Object..................... 115


What Is RegExp?............................................................................. 115
RegExp Modifiers............................................................................ 116
test()................................................................................................ 118
exec().............................................................................................. 119

Section III: JavaScript Advanced.................121


Chapter 21: JavaScrip Browser Detection................. 123
Browser Detection........................................................................... 123
The Navigator Object..................................................................... 124

Chapter 22: JavaScript Cookies................................ 129


What Is a Cookie?........................................................................... 129
Create and Store a Cookie............................................................... 130

Chapter 23: JavaScript Form Validation................... 134


Required Fields............................................................................... 134
E-mail Validation............................................................................ 136

ix
Table of Contents

Chapter 24: JavaScript Animation............................ 138


The HTML Code........................................................................... 138
The JavaScript Code........................................................................ 139
The Entire Code............................................................................. 139

Chapter 25: JavaScript Image Maps.......................... 141


HTML Image Maps........................................................................ 141
Adding Some JavaScript.................................................................. 142

Chapter 26: JavaScript Timing Events...................... 144


The setTimeout() Method............................................................... 144
The clearTimeout() Method............................................................ 149

Chapter 27: Create Your Own Objects


with JavaScript............................................................ 151
JavaScript Objects........................................................................... 151
Creating Your Own Objects............................................................ 152

Section IV: AJAX Basic................................157


Chapter 28: AJAX XMLHttpRequest....................... 159
AJAX Uses the XMLHttpRequest Object........................................ 159
The XMLHttpRequest Object........................................................ 159
Your First AJAX Application........................................................... 160

Chapter 29: AJAX Browser Support......................... 163


The XMLHttpRequest.................................................................... 163
All Together Now............................................................................ 164

x
Table of Contents

Chapter 30: AJAX—The XMLHttpRequest


Object’s Methods and Properties................................. 166
Important Methods......................................................................... 166
Sending an AJAX Request to a Server.............................................. 167
Important Properties....................................................................... 167
The responseText Property.............................................................. 167
XMLHttpRequest Open—Using False............................................ 167
XMLHttpRequest Open—Using True............................................ 168
The readyState Property.................................................................. 168
The onreadystatechange Property.................................................... 169

Chapter 31: AJAX Server.......................................... 170


XMLHttpRequest Object Can Request Any Data........................... 170
Requesting Files.............................................................................. 170
Submitting Forms........................................................................... 171

Section V: AJAX Advanced.........................173


Chapter 32: AJAX Suggest....................................... 175
The HTML Form........................................................................... 175
The showHint() Function............................................................... 176
The GetXmlHttpObject() Function................................................ 177
The stateChanged() Function.......................................................... 177
AJAX Suggest Source Code............................................................. 178

Chapter 33: AJAX Database Example....................... 184


The AJAX JavaScript....................................................................... 185
The AJAX Server Page..................................................................... 186

xi
Table of Contents

Chapter 34: AJAX XML Example............................ 188


The AJAX JavaScript....................................................................... 189
The AJAX Server Page..................................................................... 190
The XML File................................................................................. 191

Chapter 35: AJAX ResponseXML Example.............. 198


The AJAX JavaScript....................................................................... 199
The AJAX Server Page..................................................................... 201

Appendixes...............................................203
Appendix A: JavaScript Objects........................................................................203
Appendix B: HTML DOM Objects.................................................................214

Index.........................................................245

xii
Introduction

W elcome to Learn JavaScript and Ajax with w3schools. This book is for Web site
designers and builders who want to learn to add interactivity to their Web pages
with JavaScript and Ajax.
w3schools (www.w3schools.com), is one of the top Web destinations to learn JavaScript
and many other key Web languages. Founded in 1998, w3schools’ tutorials are recom-
mended reading in more than 100 universities and high schools all over the world. This
book is a great companion to the JavaScript and Ajax tutorials on the w3schools site,
which were written by Jan Egil Refsnes, Ståle Refsnes, Kai Jim Refsnes, and Hege Refsnes.
Like the w3schools online tutorials, this book features a brief presentation of each topic,
trading lengthy explanations for abundant examples showcasing each key feature. This
book, as well as other w3schools books published by Wiley, features straight-forward and
concise tutorials on each topic from which the beginning Web developer can easily learn.
All of the book’s content is derived from w3schools’ accurate, user-tested content used by
millions of learners every month.

JavaScript
JavaScript is the scripting language of the Web. JavaScript is used in millions of Web pages
to add functionality, validate forms, detect browsers, and much more. JavaScript is the
most popular scripting language on the Internet and works in all major browsers, such as
Internet Explorer, Firefox, Chrome, Opera, and Safari.

What You Should Already Know


Before you continue you should have a basic understanding of HTML.
If you want to study this subject first, please read Learn HTML and CSS with w3schools.

What Is JavaScript?
8 JavaScript was designed to add interactivity to HTML pages.
8 JavaScript is a scripting language.
8 A scripting language is a lightweight programming language.
8 JavaScript is usually embedded directly into HTML pages.
Learn JavaScript and AJAX with w3schools

8 JavaScript is an interpreted language (means that scripts execute without pre-


liminary compilation).
8 Everyone can use JavaScript without purchasing a license.

Are Java and JavaScript the Same?


No, they are not. Java and JavaScript are two completely different languages in both con-
cept and design.
Java (developed by Sun Microsystems) is a powerful and much more complex program-
ming language in the same category as C and C++.

What Can JavaScript Do?


8 JavaScript gives HTML designers a programming tool. HTML authors
are normally not programmers, but JavaScript is a scripting language with a
very simple syntax. Almost anyone can put small “snippets” of code into their
HTML pages.
8 JavaScript can put dynamic text into an HTML page. A JavaScript state-
ment like document.write(“<h1>” + name + “</h1>”) can write a vari-
able text into an HTML page.
8 JavaScript can react to events. A JavaScript script can be set to execute when
something happens, like when a page has finished loading or when a user clicks
on an HTML element.
8 JavaScript can read and write HTML elements. A JavaScript script can read
and change the content of an HTML element.
8 JavaScript can be used to validate data. A JavaScript script can be used to
validate form data before it is submitted to a server. This saves the server from
extra processing.
8 JavaScript can be used to detect the visitor’s browser. A JavaScript script
can be used to detect the visitor’s browser, and depending on the browser, load
another page specifically designed for that browser.
8 JavaScript can be used to create cookies. A JavaScript script can be used to
store and retrieve information on the visitor’s computer.

The Real Name Is ECMAScript


JavaScript’s official name is ECMAScript, which is developed and maintained by the
ECMA International organization.
The language was invented by Brendan Eich at Netscape (with Navigator 2.0) and has
appeared in all Netscape and Microsoft browsers since 1996.

2
Introduction

ECMA-262 is the official JavaScript standard. The development of ECMA-262 started in


1996, and the first edition of was adopted by the ECMA General Assembly in June 1997.
The standard was approved as an international ISO (ISO/IEC 16262) standard in 1998.
The development of the standard is still in progress.

AJAX
AJAX equals Asynchronous JavaScript and XML.
AJAX is based on JavaScript and HTTP requests. AJAX is not a new programming lan-
guage, but a new way to use existing standards.
AJAX is the art of trading data with a Web server, and changing parts of a Web page,
without reloading the whole page.

What You Should Already Know


Before you continue you should have a basic understanding of the following:
8 HTML
8 JavaScript
If you want to study these subjects first, find the tutorials on the w3schools home
page.

AJAX = Asynchronous JavaScript and XML


AJAX is not a new programming language, but a new technique for creating better, faster,
and more interactive Web applications.
With AJAX, a JavaScript can communicate directly with the server, with the XMLHttpRe-
quest object. With this object, a JavaScript can trade data with a Web server, without
reloading the page.
AJAX uses asynchronous data transfer (HTTP requests) between the browser and the Web
server, allowing Web pages to request small bits of information from the server instead of
whole pages.
The AJAX technique makes Internet applications smaller, faster, and more user friendly.

AJAX Is Based on Internet Standards


AJAX is based on the following Web standards:
8 JavaScript
8 XML

3
Learn JavaScript and AJAX with w3schools

8 HTML
8 CSS
AJAX applications are browser- and platform-independent.

AJAX Is About Better Internet-Applications


Internet applications have many benefits over desktop applications: They can reach a
larger audience; they are easier to install and support; and they are easier to develop.
However, Internet applications are not always as “rich” and user friendly as traditional
desktop applications.
With AJAX, Internet applications can be made richer and more user friendly.

Start Using AJAX Today


There is nothing new to learn. AJAX is based on existing standards. These standards have
been used by developers for several years.

How To Use This Book


Throughout this book, you will see several icons:

Try it yourself >>


The Try It Yourself icon indicates an opportunity for you to practice what you’ve just
learned. The code and examples under this icon come from examples on the w3schools
site, which allow you to make changes to the code and see the results immediately. You
do not have to type in the code examples in this book; you will find them all on the
w3schools site.

 he w3schools icon indicates that more information is available on the w3schools


T
site.

This icon indicates where you will find further information about a topic that is
covered more thoroughly elsewhere within the book.
This book is divided into five sections:
8 Section I: JavaScript Basic
8 Section II: JavaScript Objects
8 Section III: JavaScript Advanced
8 Section IV: AJAX Basic
8 Section V: SectionAJAX Advanced

4
Introduction

If you’re anxious to improve your Web pages and to add some interactivity, jump right
in with JavaScript Basic. Plenty of examples and opportunities to try things await, and
w3schools will be right there when you need them!

5
Section I
JavaScript
Basic
❑ Chapter 1: JavaScript How To and Where To
❑ Chapter 2: JavaScript Statements and
Comments
❑ Chapter 3: JavaScript Variables
❑ Chapter 4: JavaScript Operators
❑ Chapter 5: JavaScript Comparisons
❑ Chapter 6: JavaScript If…Else
❑ Chapter 7: JavaScript Loops
❑ Chapter 8: JavaScript Flow Control Statements
❑ Chapter 9: JavaScript Switch and Popup Boxes
❑ Chapter 10: JavaScript Functions
❑ Chapter 11: JavaScript Events
❑ Chapter 12: JavaScript Try…Catch and Throw
Statements
❑ Chapter 13: JavaScript Special Characters and
Guidelines

7
Chapter 1

JavaScript How To
and Where To

In This Chapter
❑ How To Put a JavaScript into an HTML Page
❑ How To Handle Simple Browsers
❑ Where To Put the JavaScript
❑ Using an External JavaScript

The HTML <script> tag is used to insert a JavaScript into an HTML page.

How To Put a JavaScript into an HTML


Page
The following example shows how to use JavaScript to write text on a Web page.
The result of this script is shown in Figure 1.1.
<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>

Figure 1.1

9
Learn JavaScript and Ajax with w3schools

Here’s your first opportunity to personalize JavaScript. Change the “Hello World”
text to “Happy, Happy, Joy, Joy!” and see what happens. The result of your changes
is shown in Figure 1.2.

Try it yourself >>


<html>
<body>
<script type="text/javascript">
document.write("Happy, Happy, Joy, Joy!");
</script>
</body>
</html>

Figure 1.2

The following example shows how to add HTML tags to the JavaScript. The result
of this code is shown in Figure 1.3.
<html>
<body>
<script type="text/javascript">
document.write("<h1>Hello World!</h1>");
</script>
</body>
</html>

Figure 1.3

Continuing with our happier version of the code, change the “Hello World!” text
to “Happy, Happy, Joy, Joy!” and see what happens. The result of your changes is
shown in Figure 1.4.

10
Chapter 1: JavaScript How To and Where To

Try it yourself >>


<html>
<body>
<script type="text/javascript">
document.write("<h1>Happy, Happy, Joy, Joy!</h1>");
</script>
</body>
</html>

Figure 1.4

To insert a JavaScript into an HTML page, we use the <script> tag. Inside the
<script> tag we use the type attribute to define the scripting language.

So, <script type="text/javascript"> and </script> tell where the Java-


Script starts and ends:
<html>
<body>
<script type="text/javascript">
...
</script>
</body>
</html>

The document.write command is a standard JavaScript command for writing


output to a page.
When you type the document.write command between the <script> and </
script> tags, the browser will recognize it as a JavaScript command and execute
the code line. In this case, the browser writes Hello World! to the page:
<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
(continued)

11
Learn JavaScript and Ajax with w3schools

(continued)
</script>
</body>
</html>

NOTE If we had not typed the <script> tag, the browser would have treated
the document.write(“Hello World!”) command as pure text and would just
write the entire line on the page, as shown in Figure 1.5.

Figure 1.5

How to Handle Simple Browsers


Browsers that do not support JavaScript will display JavaScript as page content.
To prevent them from doing this and as a part of the JavaScript standard, the
HTML comment tag should be used to “hide” the JavaScript.
Just add an HTML comment tag <!-- before the first JavaScript statement, and an
end-of–comment tag --> after the last JavaScript statement, like this:
<html>
<body>
<script type="text/javascript">
<!--
document.write("Hello World!");
//-->
</script>
</body>
</html>

The two forward slashes at the end of comment line (//) comprise the JavaScript
comment symbol. This prevents JavaScript from executing the --> tag.

Where to Put the JavaScript


JavaScripts in a page will be executed immediately while the page loads into the
browser. This is not always what we want. Sometimes we want to execute a script
when a page loads, or at a later event, such as when a user clicks a button. When
this is the case we put the script inside a function. You will learn about functions in
Chapter 10, “JavaScript Functions.”

12
Chapter 1: JavaScript How To and Where To

Scripts in <head>
Scripts to be executed when they are called, or when an event is triggered, are placed
in functions.
Put your functions in the head section. This way they are all in one place, and they
do not interfere with page content. The resulting alert box is shown in Figure 1.6.

Try it yourself >>


<html>
<head>
<script type="text/javascript">
function message()
{
alert("This alert box was called with the onload event");
}
</script>
</head>

<body onload="message()">
</body>
</html>

Figure 1.6

Scripts in <body>
If you don’t want your script to be placed inside a function, or if your script should
write page content, it should be placed in the body section. Figure 1.7 shows the
result.

13
Learn JavaScript and Ajax with w3schools

Try it yourself >>


<html>
<head>
</head>

<body>
<script type="text/javascript">
document.write("This message is written by JavaScript");
</script>
</body>

</html>

Figure 1.7

Scripts in <head> and <body>


You can place an unlimited number of scripts in your document, so you can have
scripts in both the body and the head section.
<html>
<head>
<script type="text/javascript">
function message()
{
alert("This alert box was called with the onload event");
}
</script></head>
<body onload="message()">
<script type="text/javascript">
document.write("This message is written by JavaScript");
</script>
</body>

</html>

14
Chapter 1: JavaScript How To and Where To

Using an External JavaScript


If you want to run the same JavaScript on several pages without having to write the
same script on every page, you can write a JavaScript in an external file.
Save the external JavaScript file with a .js file extension. Your results are shown in
Figure 1.8.

NOTE The external script cannot contain the <script> tag!

Try it yourself >>


To use the external script, point to the .js file in the src attribute of the <script>
tag as shown:
<html>
<head>
<script type="text/javascript" src="xxx.js"></script>
</head>
<body>
</body>
</html>

Figure 1.8

NOTE Remember to place the script exactly where you normally would write the
script!

15
Chapter 2

JavaScript
Statements and
Comments

In This Chapter
❑ JavaScript Code
❑ JavaScript Blocks
❑ JavaScript Multiline Comments
❑ Using Comments To Prevent Execution
❑ Using Comments at the End of a Line

JavaScript is a sequence of statements to be executed by the browser. Unlike HTML,


JavaScript is case-sensitive; therefore, watch your capitalization closely when you
write JavaScript statements and create or call variables, objects, and functions.

JavaScript Statements
A JavaScript statement is a command to a browser. The purpose of the command is
to tell the browser what to do.
The following JavaScript statement tells the browser to write “Hello Dolly” to the
Web page:
document.write("Hello Dolly");
It is normal to add a semicolon at the end of each executable statement. Most
people think this is a good programming practice, and most often you will see this
in JavaScript examples on the Web.
The semicolon is optional (according to the JavaScript standard), and the browser
is supposed to interpret the end of the line as the end of the statement. You often
will see examples without the semicolon at the end.

16
Chapter 2: JavaScript Statements and Comments

NOTE Using semicolons makes it possible to write multiple statements on one


line, although good programming practice encourages placing only one statement per
line.

JavaScript Code
JavaScript code (or just JavaScript) is a sequence of JavaScript statements. Each
statement is executed by the browser in the sequence it is written.
This example will write a heading and two paragraphs to a Web page as shown in
Figure 2.1.

Try it yourself >>


<html>
<body>

<script type="text/javascript">
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>

</body>
</html>

Figure 2.1

JavaScript Blocks
JavaScript statements can be grouped together in blocks. Blocks start with a left
curly bracket { and end with a right curly bracket }.
The purpose of a block is to make the sequence of statements execute together.
The following example writes a heading and two paragraphs to a Web page as
shown in Figure 2.2.
17
Learn JavaScript and Ajax with w3schools

Try it yourself >>


<html>
<body>

<script type="text/javascript">
{
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
}
</script>

</body>
</html>

Figure 2.2

The preceding example is not very useful. It just demonstrates the use of a block.
Normally, a block is used to group statements together in a function or in a condi-
tion (in which a group of statements should be executed if a condition is met).

You will learn more about functions and conditions in Chapters 6 and 10.

JavaScript Comments
JavaScript comments can be added to explain the JavaScript script or to make the
code more readable.
Single line comments start with //.
The following example uses single-line comments to explain the code.

18
Chapter 2: JavaScript Statements and Comments

Your result is shown in Figure 2.3.

Try it yourself >>


<html>
<body>

<script type="text/javascript">
// Write a heading
document.write("<h1>This is a heading</h1>");
// Write two paragraphs:
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>

</body>
</html>

Figure 2.3

JavaScript Multiline Comments


Multiline comments start with /* and end with */.
The following example uses a multiline comment to explain the code.
Your result is shown in Figure 2.4.

Try it yourself >>


<html>
<body>

<script type="text/javascript">
(continued)
19
Learn JavaScript and Ajax with w3schools

(continued)
/*
The code below will write
one heading and two paragraphs
*/
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
</script>

</body>
</html>

Figure 2.4

Using Comments to Prevent Execution


In the following example, the comment is used to prevent the execution of a single
code line (can be suitable for debugging):
Your result is shown in Figure 2.5.

Try it yourself >>


<html>
<body>

<script type="text/javascript">
//document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");

20
Chapter 2: JavaScript Statements and Comments

</script>

</body>
</html>

Figure 2.5

In the following example, the comment is used to prevent the execution of a code
block (can be suitable for debugging):

Try it yourself >>


<html>
<body>

<script type="text/javascript">
/*
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph.</p>");
document.write("<p>This is another paragraph.</p>");
*/
</script>

</body>
</html>

Your result would be a blank screen.

21
Learn JavaScript and Ajax with w3schools

Using Comments at the End of a Line


In the following example, the comment is placed at the end of a code line. Your
result is shown in Figure 2.6.

Try it yourself >>


<html>
<body>

<script type="text/javascript">
document.write("Hello"); // Write "Hello"
document.write(" Dolly!"); // Write " Dolly!"
</script>

</body>
</html>

Figure 2.6

22
Chapter 3

JavaScript
Variables

In This Chapter
❑ Do You Remember Algebra from School?
❑ JavaScript Variables
❑ Declaring (Creating) JavaScript Variables
❑ Assigning Values to Undeclared JavaScript Variables
❑ Redeclaring JavaScript Variables
❑ JavaScript Arithmetic

Variables are “containers” for storing information.

Do You Remember Algebra from


School?
Do you remember algebra from school?
x = 5, y = 6, z = x + y
Do you remember that a letter (like x) could be used to hold a value (like 5), and
that you could use the information given to calculate the value of z to be 11?
These letters are called variables. Variables can be used to hold values (x = 5) or
expressions (z = x + y).

JavaScript Variables
As with algebra, JavaScript variables are used to hold values or expressions. A vari-
able can have a short name, like x, or a more descriptive name, like carname.

23
Learn JavaScript and Ajax with w3schools

Rules for JavaScript variable names:


8 Variable names are case sensitive (y and Y are two different variables).
8 Variable names must begin with a letter, the underscore character, or a dollar
sign. (The $ character is used primarily by code-generation tools.)
8 Subsequent characters may be letter, number, underscore, or dollar sign.

N O TE There are 59 reserved words that are not legal variable names.

TIP Because JavaScript is case sensitive, variable names are case sensitive.

A variable’s value can change during the execution of a script. You can refer to a vari-
able by its name to display or change its value. Your result is shown in Figure 3.1.

Try it yourself >>


<html>
<body>

<script type="text/javascript">
var firstname;
firstname="Hege";
document.write(firstname);
document.write("<br />");
firstname="Tove";
document.write(firstname);
</script>

<p>The script above declares a variable,


assigns a value to it, displays the value, changes the
value,and displays the value again.</p>

</body>
</html>

24
Chapter 3: Javascript Variables

Figure 3.1

Declaring (Creating) JavaScript


Variables
Creating variables in JavaScript is most often referred to as “declaring” variables.
You can declare JavaScript variables with the var statement:
var x;
var carname;

After the declaration shown, the variables are empty. (They have no values yet.)
However, you can also assign values to the variables when you declare them:
var x=5;
var carname="Volvo";

After the execution of the preceding statements, the variable x will hold the value 5,
and carname will hold the value Volvo.

N O TE When you assign a text value to a variable, use quotes around the value.

Assigning Values to Undeclared


JavaScript Variables
If you assign values to variables that have not yet been declared, the variables will
automatically be declared.
The following statements:
x=5;
carname="Volvo";
(continued)

25
Learn JavaScript and Ajax with w3schools

(continued)
have the same effect as these:
var x=5;
var carname="Volvo";

Redeclaring JavaScript Variables


If you redeclare a JavaScript variable, it will not lose its original value.
var x=5;
var x;

After the execution of the preceding statements, the variable x will still have the
value of 5. The value of x is not reset (or cleared) when you redeclare it.

JavaScript Arithmetic
As with algebra, you can do arithmetic operations with JavaScript variables:
y=x-5;
z=y+5;

N O TE Sometimes the results seem unpredictable. If at least one variable on the


right side of an assignment expression contains a string value, the result will be a string
and the “+” operator is applied as the concatenation operator to the toString() values of
the variables. Only if all the variables to the right of the assignment operator are num-
bers will the result be a number.

You will learn more about the operators that can be used in Chapter 4,
“JavaScript Operators.”

26
Chapter 4

JavaScript
Operators

In This Chapter
❑ JavaScript Arithmetic Operators
❑ JavaScript Assignment Operators
❑ The + Operator Used on Strings
❑ Adding Strings and Numbers

The assignment operator, =, is used to assign values to JavaScript variables, as shown


in the first two lines of the following code.
The arithmetic operator, +, is used to add values together, as shown in the last line
of the following code.
y = 5;
z = 2;
x = y+z;
The value of x, after the execution of the preceding statements is 7.

JavaScript Arithmetic Operators


Arithmetic operators are used to perform arithmetic between variables and/or val-
ues.
Given that y = 5, the following table explains the arithmetic operators.
Operator Description Example Result
+ Addition x = y+2 x=7
- Subtraction x = y-2 x=3
* Multiplication x = y*2 x = 10
/ Division x = y/2 x = 2.5
% Modulus (division remainder) x = y%2 x=1
++ Increment x = ++y x=6
-- Decrement x = --y x=4

27
Learn JavaScript and Ajax with w3schools

JavaScript Assignment Operators


Assignment operators are used to assign values to JavaScript variables.
Given that x = 10 and y = 5, the following table explains the assignment operators:
Operator Example Same As Result
= x=y x=5
+= x+ = y x = x+y x = 15
-= x- = y x = x-y x=5
*= x* = y x = x*y x = 50
/= x/ = y x = x/y x=2
%= x% = y x = x%y x=0

The + Operator Used on Strings


The + operator also can be used to concatenate string variables or text values
together. To concatenate two or more string variables together, use the + operator:
txt1="What a very";
txt2="nice day";
txt3=txt1+txt2;

After the execution of the preceding statements, the variable txt3 contains “What
a verynice day”.
To add a space between the two strings, insert a space into one of the strings:
txt1="What a very ";
txt2="nice day";
txt3=txt1+txt2;

Or insert a space into the expression:


txt1="What a very";
txt2="nice day";
txt3=txt1+" "+txt2;

After the execution of the preceding statements, the variable txt3 contains:
“What a very nice day”

Adding Strings and Numbers


The rule is as follows:
If you add a number and a string, the result will be a string! Your results are shown
in Figure 4.1.
28
Chapter 4: Javascript Operators

Try it yourself >>


<html>
<body>

<script type="text/javascript">
x=5+5;
document.write(x);
document.write("<br />");
x="5"+"5";
document.write(x);
document.write("<br />");
x=5+"5";
document.write(x);
document.write("<br />");
x="5"+5;
document.write(x);
document.write("<br />");
</script>

<p>The rule is: If you add a number and a string, the result
will be a string.</p>

</body>
</html>

Figure 4.1

29
Chapter 5

JavaScript
Comparisons

In This Chapter
❑ Comparison Operators
❑ How to Use Comparisons
❑ Logical Operators
❑ Conditional Operator
Comparison and logical operators are used to test for true or false.

Comparison Operators
Comparison operators are used in logical statements to determine equality or differ-
ence between variables or values.
Given that x = 5, the following table explains the comparison operators:
Operator Description Example
== is equal to value...is equal to value x == 8 is false
=== is exactly equal to value and type x === 5 is true
x === “5” is false
!= is not equal x! = 8 is true
> is greater than x > 8 is false
< is less than x < 8 is true
>= is greater than or equal to x >= 8 is false
<= is less than or equal to x <= 8 is true

30
Chapter 5: Javascript Comparisons

How to Use Comparisons


Comparison operators can be used in conditional statements to compare values and
take action depending on the result:
if (age<18) document.write("Too young");

You will learn more about the use of conditional statements in the next
chapter.

Logical Operators
Logical operators are used to determine the logic between variables or values.
Given that x = 6 and y = 3, the following table explains the logical operators:
Operator Description Example
&& and (x < 10 && y > 1) is true
|| or (x == 5 || y == 5) is false
! not !(x == y) is true

Conditional Operator
JavaScript also contains a conditional operator that assigns a value to a variable
based on some condition. The syntax is as follows:
variablename=(condition)?value1:value2

For example,
greeting=(visitor=="PRES")?"Dear President ":"Dear ";

If the variable visitor has the value of "PRES", then the variable greeting will be
assigned the value "Dear President " else it will be assigned "Dear".

31
Chapter 6

JavaScript If...Else
Statements

In This Chapter
❑ Conditional Statements
❑ if Statement
❑ if...else Statement
❑ if...else if...else Statement

Conditional statements are used to perform different actions based on different


conditions.

Conditional Statements
Very often when you write code, you want to perform different actions for different
decisions. You can use conditional statements in your code to do this.
JavaScript has the following conditional statements:
8 if statement. Use this statement to execute some code only if a specified condi-
tion is true.
8 if...else statement. Use this statement to execute some code if the condition is
true and another code if the condition is false.
8 if...else if....else statement. Use this statement to select one of many blocks of
code to be executed.
8 switch statement. Use this statement to select one of many blocks of code to
be executed.

32
Chapter 6: JavaScript If...Else Statements

TIP With conditionals, a { } block must contain the statements to be executed. If


curly braces are not present, only the subsequent statement is executed, which is a very
common programming error.
if (condition)
{
statement 1;
statement 2;
statement 3;
} // all three statements are executed

if (condition)
statement 1;
statement 2;
statement 3;
// only statement 1 is executed

if Statement
Use the if statement to execute some code only if a specified condition is true.
The syntax is as follows:
if (condition)
{
code to be executed if condition is true
}
Your result is shown in Figure 6.1.

TIP if is written in lowercase letters. Using uppercase letters (IF) will generate a
JavaScript error!

Try it yourself >>


<html>
<body>

<script type="text/javascript">
var d = new Date();
var time = d.getHours();
(continued)
33
Learn JavaScript and Ajax with w3schools

(continued)
if (time < 10)
{
document.write("<b>Good morning</b>");
}
</script>

<p>This example demonstrates the If statement.</p>


<p>If the time on your browser is less than 10, you will get
a "Good morning" greeting.</p>

</body>
</html>

Figure 6.1

N O TE There is no ..else.. in this syntax. You tell the browser to execute some
code only if the specified condition is true.

if...else Statement
Use the if....else statement to execute some code if a condition is true and
another code if the condition is not true.
The syntax is as follows:
if (condition)
{
code to be executed if condition is true
}
else
{
code to be executed if condition is not true
}

34
Exploring the Variety of Random
Documents with Different Content
movement you describe is. I have no fear if the people now interested
can only be kept working with some result, enough to keep up their
hope; if so, the things must grow.

Freshwater Place,
1879 or ’80.

Miss Emily Harrison to Octavia.

I got two nice little letters from children, when I was away. I heard
they took my answers, and read them to the other children in the
Playground. Wasn’t it nice of them? I send you my little neighbour’s
artistic efforts; he is only a little chap. They had trained my scarlet
runners, and left everything just as it was in my room, and welcomed
me back so tenderly, saying the place had felt empty and dull without
me. A girl, who has a lot of sisters to mother, came to tell me she had
found the motto she liked best, “Love is the greatest force,” evidently
learnt from experience; for they are all so fond of her. She and four
sisters, and other little and big neighbours, came yesterday to work
for an industrial exhibition we are going to have; and whilst they did
needlework and pasting, etc., we read the “Fairy Spinner.”[92] I think
M. H. was really the only one who could listen to it, as she has been
ill and didn’t feel the excitement of the novelty so much as the others.
Some of the dear little tots kept running past crying to the swallows
and butterflies painted on the wall, “I’ll catch you bird,” “I’ll catch
you butterfly,” almost as happy, dear, as if they were real ones, I
think.... We came home to that dear Haven named Miranda, looking
so sweet and rested and full of delightful sayings and doings of other
people. Can’t you see her upturned face telling them, and a twinkle in
her eyes at something funny?

ART IN
FRESHWATER
No date. (Probably 1879.)
PLACE
From Miss Emily Harrison.

Dearest Octavia,
Oh if one could but have a penny botanical garden in the
Marylebone Road for the hot little children and weakly old people!
“Now I hope you’ll enjoy yourself,” with a hearty grasp of the hand,
as much as to say, “You must now,” was the last word I heard at
Freshwater Place.
I didn’t at all like leaving it. The children enjoyed their field day
very much, I think, and kept asking, “Wasn’t it nice on Saturday?”
with such a little hug of your hand! I was so pleased with one child,
who, I knew, in the midst of amusing herself, simply to give me
pleasure, came away to me with, “Won’t Miss like to have a game of
six acres of land?” and the girl with the dreadful face behaved
splendidly, and carried poor little Shannon all the way home to Swiss
Cottage; for we nearly killed the poor little fellow. The cab-door burst
open, and he was shot out, and I expected him to be killed on the
spot. But on Sunday he was on his legs again—quite a hero; and
instead of pitching into me, his parents were so kind; only too
anxious to reassure me, and show how well he could walk. In fact,
Johnny has come into notice ever since. I had a nice talk with grave
Mrs. Wilson, who is going to lend books, and to honour me by
getting me a cup of tea there; and I went to say, “How d’ye do?” and
“Good-bye!” to B. Court Club, and found Mrs. Lewes there.
She was so pleased to get her rents all right; but also disappointed
at many things. It seems that it is when everything looks like failure
that courage comes from some bright spot, or something to start you
afresh.

From a Lady helping in B. Court.

The cobbling class that I have superintended since the 2nd of


December has kept up, as well as I could expect, in some respects,
and very much better in others; for, though it has not increased in
numbers, some boys have never missed coming. They have really
learnt to mend well, and have improved so wonderfully in their
manners to each other and to me, that, in three or four cases, we
have got really fond of each other, and that is my hope for the future.
Good, I like to think, may result. Nine boys attended the last evening,
and seemed very sorry that it was the last, asking if, next winter, the
class would be again; and, as they have once or twice hinted their
hope of my taking them for something else in an evening, I am going
to try; and we shall read English History to begin with, and talk, and
so on; for we are really so comfortable with each other that just to be
together is a pleasure to us now. They are only young. But I found
that they and older boys did not do well together.... The boy beyond
all the others whom I care for is James ——; and as I fear you may
have heard anything but good of him—for I am the only one of your
ladies who has any liking for him, except, I think, Miss Leighton,—
perhaps it may be a mistake to like James as much as I do, and to
hope that he will do so well. But I am quite sure that if you, dear Miss
Hill, had the same cause as I have to admire all his ways and work
that I can see, you would also care little for what is said about his
mother and father. The first evening that he came he did nothing but
watch me, and stand, rather rudely, with his cap on all the time. Also
he had brought no halfpenny; and I told him that just for that
evening he might stay, but that another time he could not without
paying.
THE BOYS OF B. His large head and the powerful expression
COURT of his face made me think how bad, or how
good, he might be, according to the way he turns. I heard that
evening that he was one of the worst (English “troublesome”) boys in
the Court. To my surprise he came the next time with his halfpenny;
and, when I said that Lush the cobbler was late, he offered very
civilly to go for him. I thanked him, and made much of him. During
the evening he worked more steadily than any of them; and ever
since he has been my best boy, both as regards working, and coming
even when he has nothing to mend, just because he seems so happy
to be there and to do any little thing that he possibly can for me. Mrs.
Jales says that he is now much better in the Court too. To say I like
him says little, for I do a great deal more than that. A woman would
be strangely made who did not get to feel him as somewhat her own
property, and, even if he goes wrong afterwards, not to lose her
affection for him easily.
Braemar,
September 16th, 1879.

To Mrs. Shaen.

In an age when doubt assails so many young spirits with its light
destruction of belief in the eternal and intangible, will not the
possession of such a brother be perhaps to the elder ones something
no other possession could be? Those who have never loved and lost
may think of the dead as buried and done with; those whose lost ones
had nothing noble or specially characteristic which was good about
them, may think of them as having lived; but whoever has seen and
loved a being with peculiar beauty and nobleness, will have
moments, and those the best and deepest in life, when the certainty
that that being still lives, will be quite quietly triumphant over all
clever talk or brilliant flippancy. I think to you all Frank will be
always a blessing—in spite of pain.

OPEN SPACES On the attempt to save the site of Horsemonger Lane


PRESERVATION Gaol as an Open Space.

Braemar,
September 24th, 1879.

To Mrs. Edmund Maurice.

I think we could get the Archbishop to hold a meeting. In fact I


have no fear about getting money, if dear E. can only get it into a
working shape where that only is needed. After all, even if
Government did give it, that only means all being taxed; and surely,
so long as riches exist, there is need to call upon those who have
them to give of their abundance freely and heartily to such places as
Southwark; even without asking them, to make it possible for those
of them who want to give to give helpfully, and, so long as there are
even quite poor people with any surplus, it is a pity they should not
have the joy of giving freely. Is it to be all compulsory taxes, and no
free-will offering?

B. Court Club,
October 18th, 1878 or 1879 (?).

Gertrude to Octavia.

Mr. Blyth asked to come to see me on purpose to know what I


thought about things. He is very hopeful, much pleased at the quiet
dignified way in which the (Temperance) Lodges men behaved. They
asked the old men (who are chiefly boys) what they meant to do
about the debt, and their reply was that, if they could not meet it
otherwise, they must sell the furniture, billiard tables, etc.! So,
finally, the teetotalers have formally taken the debts (now said to be
£5) upon themselves, and have also taken the tables, etc., as part of
the club belongings.
There were, last week, forty-five new teetotal members, and there
are twenty-four non-total abstainers—sixty-nine in all. Seventeen
and threepence was paid in entrance fees, the whole room cleaned
and put in order; and Grimmins’s first act was to fasten up with his
own hands, in the renewed room, the tablet to Mr. Cockerell’s
memory. They want it to be just as it all was at first, and to have a
penny subscription and no ballot at election.

Eland House,
November 3rd, 1879 or ’80.

From Mrs. Edmund Maurice to Octavia.

We went to the opening of Walmer Castle, which was a great


success. There were large crowds both of rich and poor. Among
others Mr. Hughes, Mr. Hart, Mr. Davies, Mr. Diggle, General
Gardiner, Charles and Gertrude. After the “public” had been
admitted to the tap-room, and before they began making their
purchases, speeches were made by one or two people. Mr. Hughes
made a very nice speech, and so did Mr. Diggle, who was much
applauded. He came up and asked very warmly after you, and said
you would be glad to hear that all the work in St. Mary’s was going on
well, and some of it was being carried on with more vigour than ever.
Miss Cons looked very happy, and was busy talking to everybody.
The whole place looked very clean and comfortable, and all the food
very nice; there were decorations of flowers, and bright flags flying
outside. We went over the house, and saw the beautiful dining-room
upstairs and the smoking-room, and some very comfortable
furnished little bedrooms for respectable men. General Gardiner
turned to a friend and said, “We should some of us have been very
glad of as good a bedroom as this at the University.” My fear about
the bedrooms is that they are too dear. A shilling a night is not much
to pay for so nice a little furnished room; but, if a working man has to
pay seven shillings a week for his room, I fear he will think it too
much. Downstairs there is a nice large room to be used for the Boys’
Club. It is to be decorated by the Kyrle Society.

WORK OF THE
KYRLE SOCIETY
14, Nottingham Place,
October 17th, 1879.

From Miranda.

I don’t know whether Minnie will write and give you any account
of the Kyrle Committee Meeting yesterday; but, in case she does not,
I think you will be glad to know that all went, I think, very
satisfactorily. Your letter was received with pleasure, and your offer
of transferring the St. Christopher work to the Kyrle was received
with warm thanks. Somebody is to be found to undertake the
drawing.... Can you tell me where your large St. Christopher is? I was
asked to show it yesterday, that the Committee might see how much
needed completing.
The money was voted for the choir without any difficulty. We have
two applications to decorate rooms for working girls.
Minnie asked, on behalf of the O.S. Committee, whether they were
at liberty to appeal to the public for funds without consulting the
General Committee on the subject. It was decided that they could
not. Mr. N. said that he thought they never ought to take any public
action without consulting the General Committee. We explained how
impossible it would be to work at all, if no public action could be
taken without reference to the General Committee; for all the work is
dealing with public bodies, vestries, etc., and, when Minnie pointed
out that in any doubtful case like Burnham Beeches, the O.S.
Committee always had, and always would, consult the General
Committee, Mr. N. was satisfied.

14, Nottingham Place, W.,


December 15th, 1879.

Octavia to a Volunteer Worker.

In order to bind the work in the Court (not the collecting, to which
this letter does not refer at all) and to make the arrangements
simpler and more organised, it is proposed to unite the teachers of
the evening classes into a little Committee.
I hope you will be able to join this Committee. I do not think that it
will involve you in any labour which will not be very easy, even to so
busy a person as you; while it would, in many ways, save you trouble
in making arrangements a little more organised and easy to deal
with. I think you would all enjoy the little reason for meeting from
time to time.
Unless any unforeseen business presents itself, I should think two
meetings in the year would be ample; one to settle summer and one
winter arrangements, for it is proposed to leave everyone utterly free
to do on their evening precisely what seems good to them, so that the
only questions that the Committee would have to deal with would be
those which might clash with or influence other workers, or in which
they would wish to have a voice. My sister, Mrs. Edmund Maurice,
will be Secretary of the little Committee. There would be five
members, including yourself; but if large questions of general
interest were coming before the Committee, it would be well to invite
the other workers in the Court to attend and vote, as the landlord is
anxious for the room to be as generally useful as possible, especially
as Lady Ducie has given up hers to the general use of the Court so
entirely by giving the use of it to the Club. I am not without hope that
I may have the great pleasure of seeing the Committee meet just once
here, after Xmas, before I go. I hope rather great things from it, do
you know? I feel how much the life of the Court has developed since I
left. All of you seem to me stronger and quite knowing your own
strength, which is an immense help. The work is more individual,
more living, more firmly rooted; but I don’t like to think that you
should lose anything by my absence; and I sometimes dare to hope
that this little Committee might, while leaving to each of you full, free
scope, give you each the little connecting link you seem as if you
might lose in losing me. I mean the power of all meeting for common
work, of gathering strength each from the other, of adding power and
life each to the other’s work, of knowing and meeting one another, of
understanding each what the other means, of pausing for a moment
to see if there is anything to learn, to accept, to use in the other’s
work, the sense of a common cause and of being one body to
interpret that common cause in the noblest way in which it can be
conceived, and to sink all little narrow views in the broadest and
deepest ones.

GROWTH OF
WORK IN
Rome,
OCTAVIA’S February 18th, 1880.
ABSENCE
To Miranda.

What an interesting account you give of Mr. Clifford’s discussions!


I believe few people will grasp what he meant the main point of the
discussion to be; but I do believe they will be very useful, if they
show people who are doing tangible good, or good less spiritual, that
distinct teaching about God Himself may be needed. I think the
reaction from doing that only has been too great, and that I and
many people need to be reminded of that deepest way of work; tho’ I
think we always take it up when we have the power, but we hardly
look out for, or abundantly use, the people who have the power, nor
cultivate it in ourselves. I think it is the next thing we have to aim at.
In fear of undue pressure, we hardly appeal bravely enough to the
indwelling power of response there must be in every one.
Brindisi,
February 20th, 1880.

To her Mother.

... I am glad you like the Diary of an Old Soul. I think MacDonald
singularly excels in that quaint, simple, deeply religious poetry.
Somehow he has naturally the habit of making those queer
comparisons, and sudden leaps from great to small things which one
finds in the old poets; and, in the same way, his deep faith atones for
the strangeness. There is even something captivating in it. I think the
book very beautiful. I went to see Mrs. Grey in Rome. She was so
very kind and nice, and so interesting too. We talked of old times,
and of the Public Day Schools, and the Kindergarten work. We also
saw the Marshes.... Yesterday we came from Beneventum here. The
day was wild, and there was even rain; but it was very interesting,
first to cross the watershed between the Adriatic and Tyrrhenian
Seas, then to traverse the great plain lying round Foggia, where four
and a half million sheep used to graze, returning in winter by three
great roads called the Strade dei Pecore. The merino sheep used to be
there, now the plain is gradually being cultivated; but there are still
half a million sheep, and one sees herds of great grey cattle, and
droves of 40 or 60 horses, looking almost wild, grazing among the
glades of oak trees, or on the open ground.

CO-OPERATION
WITH CLERGY
February 21st, 1880.

Miranda to Octavia.

One of the lady workers was talking of giving food to one of the B.
Crt. men, who has been ill; but I found he had just got into work, so I
suggested he could get on for himself now. I then explained to her
that your plan was to let St. Thomas’s Relief Committee do any
absolute relief, and then to strengthen them with gifts, if you can
make any. She was so much interested, and very glad to know it. She
said that she had no idea you worked with the Church authorities to
that extent. She knew you were a member of the Church, but had no
idea you co-operated with the clergy to that extent. So many people
thought you chose to be independent. I explained how anxious you
were that the clergy should be willing to be co-operated with, and
told her that your desire was to work with them and so was that of
the C.O.S. if they would but be worked with.... Mr. E. writes: “Will
Mr. M. contribute to the Thirlmere Defence Fund? He may be
induced to do so when he remembers Miss Octavia Hill’s words”
(evidently some words you spoke some time ago).

Hotel St. George, Corfu,


Tuesday, February 24th, 1880.

To her Mother.

We reached here on Saturday. We found no post left here for


England till to-day; I hope you will not have thought it very long
before you heard. We had a splendid passage here.... I lay on the deck
nearly all day, and saw the wild, blue, beautiful Albanian shore, such
a land of bare wild mountain-land. The name of the people means
“Highlander.” Then we floated past the islands and into the narrow
sea between Corfu and Albania, where the Venetians and Turks had
their last sea fight, and the Turks tried no more to advance into
Europe. It was a glorious light as we floated into Corfu about half
past. When we had passed thro’ 13 miles of this forest country with
the mountains in view, and here and there, but very far between, a
village or two, we came out on a cliff over the sea, along which we
drove three miles. The road had been made by the English soldiers,
but it is now all going gradually to pieces; the arches which support
the bridges over the little streams (which, by the way, are now quite
dry) are all cracking, their keystones protruding; the well-built walls
supporting the road on the slope of the hills are crumbling gradually
down, taking the road with them. Great hollows are appearing in the
road, and large stones in thousands rolling down upon it. The driver
said, “Il governo non fa niente per la strada.” And there it is
crumbling to decay. It does seem a pity.
We are going on board the Greek boat to-day en route for Athens.
We hear the “roughness” only consists in the want of good food; that
the boat and arrangements are good. There is at any rate much less
open sea, and the scenery is finer. An English lady who sat by me last
night said she had been both ways and much preferred ours, but the
gentlemen here make a great talking about the food. I daresay it will
do for us. I am doing very little drawing and no good with it; but it is
possible I may later, and this sea could not be attempted without
emerald green.

CONDITION OF
PATRAS
Athens,
February 28th, 1880.

To Miranda.

Patras, their new commercial city, is nearly as pathetic and nearly


as interesting as modern Athens; and one feels that from there actual
safety, as well as education, and even the possibility of seeing the
beauty, must spread gradually. The difficulties of travel are quite
extraordinary, quite independently of the question of safety. There
are no hotels, no lodgings, no beds, hardly any food, no relays of
horses, no posts, no accurate guide-books, no trustworthy people to
give information. And somehow one feels it will all come gradually
from this little town, springing up, as it were, yesterday, with its little
throb of life, which must permeate the whole before it can be healthy
or alive. Even from a tourist’s point of view, mountains and woods
and defiles and rivers are no use because you can’t get at them; and
what of the life of the people, their education, their power of using
the good things that the earth brings forth?

Hôtel des Étrangers, Athens,


March 3rd, 1880.

To her Mother.

Mrs. Coupland’s introductions have been most useful.... Dr.


Milschaefer came himself to give us a lesson in modern Greek, and
brought such an interesting young Greek to teach us the
pronunciation. It is very interesting to see how the young national
life is flowing instinctively in the old grooves. The great thing they
have progressed in, since their independence, has been education.
Their University is evidently becoming remarkable, and people are
coming from Asia Minor and Turkey to study. Their girls’ schools
and boys’ schools are evidently what they feel they are succeeding in.
They regret, however, that everyone tries to be a lawyer or something
of that kind; and that agriculture and manufacture are neglected.
Evidently agriculture has a great future here. The country is much
less fertile than in olden times, partly from the bad systems of
cultivation, partly, I should guess, from the neglect of trees. They
excuse themselves by saying that the ancient Greeks had slaves; but
one feels free men ought to work as well as slaves! and one can see
they know they ought to do better. One great want is population.
They can and do live by the rudest systems of culture. I daresay the
utter insecurity of country life, which for years (I suppose ages) has
prevailed, will have prevented anyone seeing to, or caring for,
farming. The Greeks look as if they had much more stamina than the
Italians. I fancy their sea life has kept it up; and perhaps their
mountain fastnesses, and the fiercer oppression have really been
better for them than the enervated life of Italian cities under
Austrian, or despotic, cultivated home rule, where the richer and
nobler classes must have had the ease of civilisation without the
responsibility or duty of self-government. But this is all theory to
account for the greater energy one sees. Certainly the Greeks seem to
me to have dealt really well with brigandage, in contrast with the
Italians. After that dreadful affair in 1870,[93] the House of Deputies
enacted a law for four years, punishing the relations of those who
were with the brigands, and the villages near which it occurred,
which law the English minister here tells us, really extirpated it in a
few months, so that the English consuls were able officially to report
that, except on the borders and in Thessaly, it no longer existed.
Brigandage broke out some time ago in Acarnania, and they instantly
re-enacted the law, and it disappeared. It seems to me wise and right
in cases where, as here, the crime could only exist by reason of the
collusion of the surrounding people. And it must be much kinder
than dallying on, as the Italians keep doing in Sicily, first sending
and then withdrawing troops. Mr. Corbett was so kind. Gen.
Gardiner got me a letter of introduction thro’ Mr. Eric Barrington,
who is Secretary to Lord Salisbury; the letter was evidently a very
kind one. Mr. Corbett called at once, and gave us full and kind
assurances and directions as to our movements. The border land is
evidently, as every one has said thro’out, quite unsafe; but
everywhere else confidence has been quite restored for some years.
We have the very best advice, and shall strictly follow it, so you need
not have any fear. By the way, do you know those four poor
gentlemen were given a large escort, and they insisted on galloping
on, and leaving them two miles behind!! So Mr. Corbett told us. It
really makes a great difference as to the blame attached to the Greek
authorities.
BRIGANDAGE IN We went up Mt. Pentelicus on Monday. The
GREECE day was not fine, it was wet and cold, and we
had no view from the top; but I did enjoy it so very much. The
colours of all the wild landscape near were so exquisite ... I never saw
such lights, even in Italy. (Here follows an account of flowers found,
and the difficulty of identifying them without botany books.) I never
shall forget the sunset light coming back last night, as we saw it on
Pentelicus, Parnes and Hymettus, and on the Acropolis of Athens.
There was the grey-green foreground of stone and dead thyme; the
red ground here and there ploughed up, the grey-green olive, or full
dark pine, set far and far between; then there were the blue
shadowed sides and bases of the mountains and their snow-covered
tops, now in blue shadow, now in rose-coloured light, and then all
the sun-lighted sides of the mountains were rose and gold; and the
blue-green sea, turned in places into one silver sheet of ripple, broke
on the shores with sweet musical voice. It was like a dream of perfect
beauty.... Mrs. Corbett turns out to be a cousin of Lady Ducie’s, and
writes most warmly about seeing me.

About difficulties in the school.

Athens,
March, 1880.
Octavia to Miranda.

Something has set the girls out of tune. I know how trying it is, and
how the sense of it shuts one up, and makes it impossible to be
oneself, or to trust to them. But I believe, if one could remember at
such times what depths of better things there are in every human
heart, and how they only need to be believed in and appealed to
(especially in these young things), to spring up and grow and thrive,
one would more quickly get past these trying times. There is usually
either some stupid misconception, or false standard of what is
desirable, confusing the young mind, some phantom, which seems
good to it, and is not good; or else some real evil, which the child
herself knows to be evil, and against which she—the better self—will
side with you the teacher, if you can but assume that she is ready to
do so. One may beat about the bush for any length of time, by dealing
with manifestations of wrong; but if one can get near people, and get
their spirits into harmony with God’s will and purpose, and make
them feel that one only wants that done, one strikes at the root of the
evil, and loses at once the sense of jar, because it is lost in the sense
of harmony with the good in people.

GREEK SCENERY
Hôtel des Étrangers, Athens,
March 10th, 1880

To her Mother.

... I suppose this will reach you a little before your birthday (tho’
that seems hardly credible); let it bring you my loving wishes for all
that is brightest and best. We went on Saturday to Tatoë, which is a
little place on Mt. Parnes, where the king has built a little place for
summer. It is close to the old pass of Dekelea, which the Spartans
fortified, and held during the Peloponnesian War. It was a glorious
day, and we thoroughly enjoyed it; Mt. Pentelicus looked quite
beautiful. There is a great quantity of fir wood near the king’s place.
They have cleared away trees here and there; I fancy, to let one see
the giants of the native forest, which stand magnificently, throwing
their arms up in the sunshine, a foreground to the blue mountains.
The ground was covered with wild golden crocuses, blue anemones;
and, here and there, if a little bit of land was sown with corn, there
were great crimson anemones growing among it. The utter solitude
of the country is so strange here. One drives for miles, and hardly
sees a creature. We drove on Monday to the Bay of Phalerum, and
spent the afternoon at the Acropolis, and saw the sunset from there.
Yesterday a wild, tearing wind arose. We were to to have gone to
Phyle, and the mules had been sent on; but the storm of wind raged,
so we did not attempt it; in fact we could hardly stand on the hill of
Areopagus, or beat our way back along the streets, when we returned
from seeing the theatre of Dionysius, and the Stadium. We spent
Sunday evening at Mrs. Corbett’s, and last evening at Mrs. Finlay’s,
and met Mr. and Mrs. F. Noel. They go to Eubœa soon, and we shall
follow soon.... As I sit, I see the snow heavily falling between me and
the cypress trees. It does look so out of place.... Every one agrees in
one united testimony as to the extinction of brigandage.... Here it is
pretty to watch the restored confidence, and the life that is able to
grow up under it. They seem to be very cautious still, and send
mounted gendarmes out over all these solitary roads; but it is nice to
hear the pride with which the gendarme tells you you can go
anywhere.... People are beginning to build little houses in the
country, and there are other marks of confidence. How interesting it
is to hear, on all sides, of the love of education! It seems quite innate;
the children clamour to be taught, and especially do they delight in
politics. They had no toys till lately. Old Mrs. Hill, who first
established schools here for girls, forty years ago, says she never sees
the toy-shops without remembering how she brought the first dolls
to Athens, and tried to teach the children to play. She says they all sit
down to read; boys and girls stand at the corners to discuss politics.
Children used to walk from Eleusis and back to attend school here.

GREEK POLITICS
Athens,
March 18th, 1880.

To her Mother.
We saw, some few hundred yards from the hamlet, an old, broken
marble pillar placed there to mark from the surrounding hilly open
common a tiny space separated by a rough ridge of earth from the
common; but even the ridges had gaps in them, one of which led to a
stony path. We followed it, and found ourselves in the churchyard. A
few graves, marked with little crosses, and planted with sweet
rosemary, gathered round one which alone had a stone, a little
railing, and a young date-tree planted at each corner. To our
astonishment, we found the inscription in French. It was: “Oh you
who pass by, pause and know that here lies an angel who waits for
thee beyond there, Beatrice B.... who died in her 15th year, 1877.” It
was so simple, and, having no surname, seemed to mark this more.
We wondered whether French people were the cultivators, and what
was the history. The people were all Greeks at the house doors in the
hamlet, and we don’t know enough Greek to ask who has begun the
cultivation. Still, we are getting on fast with our Greek. We often wish
we knew more. There is an exciting ministerial crisis here—M.
Tricoupis, the Liberal candidate, trying to overthrow, on financial
questions, M. Koumondouros, the Conservative. People say M.
Tricoupis is the man of most principle, but that he has not a strong
party. Some of the deputies stay at this hotel, and every night at
dinner they have a hot argument; but we cannot even follow the
main drift—we only catch a few words here and there. If we knew
more, we should learn much more. We have had a Greek master
every night, and have been learning the grammar, when Miss Y.
would let me; but it is slow work till one gets to the point of hearing.

Hôtel des Étrangers, Athens,


March 20th, 1880.

To Miranda.

... There seems so much to tell you of what we see here. I feel
always as if I ought to dash into a sort of swift summary of journal,
instead of writing, as I should like, about all the things you tell me. I
am sure you know how my heart and thoughts follow you all in them,
and I think you will like to know many things I am seeing.
A SYMPATHETIC The weather has been so wild and wintry
TEACHER that we are glad to be settled here, and shall
not move till it is assured spring time. Meanwhile, we are seeing
things within a drive, learning Greek, and trying to gather what we
can about modern Greek life. Yesterday we went to see Mrs. Hill’s
day school for girls. Dr. and Mrs. Hill came here nearly fifty years
ago; their work has been supported by the Americans. This school
was the first house built in Athens among the hovels. They used some
foundations of an ancient market, and say the steps of the school,
which were found when they were digging the foundations, may be
those up which St. Paul stepped. Dr. and Mrs. Hill built their own
house at the same time; and it stands in quite the poor part of
Athens, the palace and all the better houses being later, and forming
a new quarter. Dr. Hill is now quite blind, and Mrs. Hill too old to
teach; but a vigorous and most sympathetic Scotch lady, Miss Muir,
lives with them, and carries on their work. I was delighted with her;
she and they seem to have been animated with the true spirit of trust
in the people, love for them, and desire, not to proselytise, but to
work with all that is good and pure in what the people themselves
believe—to strengthen that, instead of dwelling on differences. Hence
they have never found any difficulty in working with the Greek
priests. The lady who was with us kept pressing difficulties upon
Miss Muir, and asking her if she was not hampered by this or that;
and it was very beautiful to hear her answers. “Have you not great
difficulties in not being allowed to read the Bible?” “No,” said Miss
Muir; “we read it from end to end if we wish.” “But how about the
Greek doctrine and the procession of the Holy Ghost?” “O, the
Filioque! we haven’t to touch upon it any way! Do you know there is
a little school at the foot of Mount Parnes, from which the priest
wrote, asking if we could spare any old spelling books, or maps, or
school things, and we gathered together what we could; since which,
we have always been interested in the school. And some time ago the
priest said they would like some copies of the Bible. I wrote to
America, and they sent out twelve copies of the New Testament.
Twelve of the elder lads and the priest walked all the way to Athens
one day, in pouring rain, to receive these. Some months after they
wrote to say that, in reading the New Testament, so many questions
came up for which they wanted to refer to the Old Testament. ‘Might
they have the Pentateuch?’ So I wrote to America again. When the
books came, I drove to Parnes to take them. The priest was absent for
a few hours; on his return he rang the great village bell, and all the
peasants assembled, and the great boys came forward to receive their
books, and I wrote their names in them. ‘Tell me,’ I said, ‘is it true
that you read these? So many people say you don’t.’ ‘Every day,’ he
answered, ‘we have our food of necessities, and something to give it a
relish; so daily we have our lessons, and something to give them a
relish.’ Many missionaries tell the people they should not cross
themselves. To me,” she said, “it is beautiful to see them do it, when I
remember what centuries they have lived under the Turks, as a
despised and oppressed nation, and think what it must have cost
them to make that cross publicly, as they do when they pass a
church. It is the assertion of their Christianity. I sometimes ask
myself how many of us would have power to make that cross?”
“But aren’t you obliged to have a priest come in and teach?” “No,”
said Miss M.; “many come in as friends, and we always invite those
we know to the examinations and gatherings; and we have a large
number of priests’ children as scholars, but in this school we never
had a priest to teach. In Mrs. Hill’s other school she often had a
young deacon as pupil teacher. She used to prepare her Bible lessons
with him. They are very ignorant, and were delighted to learn and
then teach.”
All the human sympathy was so quick and so deep. She showed a
tiny orphan boy of 4, left by his mother, at her death, whom they
placed in school, to live with the teacher. We asked for a Greek
teacher, and she recommended one of two orphan pupil teachers, to
whom they had given rooms in the building. All the education in
Greece, of rich and poor, was initiated by Dr. and Mrs. Hill. They
have still this school of 700 boys and girls, and train their own
teachers; but the larger work they helped the Government to start,
and then gave it up to them.... I wonder what will be done about the
unveiling of St. Christopher. They are not Lady Ducie’s houses, you
see. I should like a little ceremony; but it is difficult to imagine a
simple natural one, and there seems no place for it.

CHARACTER OF
TRICOUPIS
Athens,
March 25th, 1880.

To her Mother.

I wonder how you are. It seems so strange not to know. We went to


see Dr. and Mrs. Hill the other day. Such quiet interesting beautiful
old people. They remind me of Quakers. They are beloved and
respected by every one, Greek and English, poor and sick, and seem
to be the only missionaries who have won the people’s hearts, by
trying to get them to do better in the way their consciences told
them. They are full of stories of all they have seen. They came after
the battle of Navarino. The Turks were still here for two years after
they came; but the protocols were signed, and the Greeks were
preparing to return. They told us lovely loving little stories of the
people they had known; of their first teacher, a Greek girl from Crete,
who came to them as a child, and became like a daughter to them,
and of many of their protegés; but all in the same honouring,
affectionate way people speak, who have the power of drawing out
what is good in those they meet. There has been the wildest
excitement here about the change of ministry. M. Tricoupis has just
succeeded M. Koumondouros. Mr. T. seems to be universally
respected. The English say he is the Greek they trust. The Greeks say
he is before the age, too good for the time, &c. He is the son of a
much respected Greek who was for years envoy in London; and he
and his sister are supposed to owe much of their enlightenment to
English influence; they are much attached to England. His main
object is to abolish the payment of a tenth part of the agricultural
produce to the Government, which is supposed to press heavily on
the people. We hear that it was one great cause of the War of
Independence; but it has never yet been altered. He is also
understood to be most anxious to alter the practice now in force here,
according to which every Government employé, from post office
clerks upwards, changes with the ministry. It seems there are
£2,000,000 of uncollected taxes in Greece now, the arrears being
largely due to the tax-collectors being unable to employ any
compulsion, the debtors simply threatening not to vote for the party
which enforces payment. There are 500 doctors and 500 lawyers
trained here in the University every year; the doctors, they say, do
very well, for they go off into the villages in Asia Minor and Turkey.
They are trying to improve the education of the priests, and train
many; but only five out of every one hundred remain priests. But it
all sounds to me like the swift cultivation of a large number of
educated men, who must help. It is clear that party feeling runs high,
and it is difficult to be sure with what bias statements are made; but,
various as are the views, the statement of facts is curiously
unanimous; and one listens to the quiet people who sympathise and
talk quietly, as well as to the bursts of indignation and scorn; and we
seem to learn a good deal. As I say, the facts that all tell us are much
the same. We were fortunate yesterday, in being taken to Mlle.
Tricoupis. She was very kind; her brother, of course, was too busy to
be seen, and she was very tired—she had been receiving till two
o’clock the night before, all the Greeks calling to offer
congratulations to the new Prime Minister; but she was very kind
and talked some little time, tho’ not about any of these burning
questions. We are to go again....

UNVEILING ST.
CHRISTOPHER
Athens,
March 26th, 1880.

To Miranda.

I shall be so glad if anything is managed in the way of a little


ceremony in Bts. Crt. for St. Christopher. I see many difficulties, but
I should like it. I am specially glad if it leads to telling the people the
story. Will the unveiler read one to the people, I wonder? And where?
It seems a pity there is no space in the court where the people can
gather. I had been wondering what could be devised in the way of a
ceremony, and had thought of little medals with date and motto to be
given to eldest and youngest child in each family resident there a
given time, and their marching in procession thro’ St. Christopher’s
room to receive them, with music and flowers and flags; but I think it
would mean a great deal of labour. I think these common memories
good for tenants and workers. I don’t much fear stone throwing; but
one never quite knows how people will see things; one may throw a
stone where fifty look with interest. I hope and believe they will like
the thing; but if anything does happen I am always ready for failure
in preparing the hearts of people for any new thing; some one must
pay the cost in disappointment. I am quite willing to do so.

Athens,
April 1st, 1880.

Octavia to her Mother.

... We went up Pentelicus and had a lovely day. It is a splendid view


from the top. One sees Eubœa with its long range of snow mountains
and its narrow strait, and Helena and Andros and the mountain
ranges of Parnes, Cithæron and Parnassus; and Hymettus, and
Athens and its plain; below lies Marathon with its red soil and blue
bay—indeed blue bays of the sea seem to be around one almost
everywhere. Last evening we spent at the Hills’. Mrs. H. was saying
that letters, when first they came here, were 7 months coming from
America; that they could negotiate no bill of exchange here; when
they wanted money Dr. H. used to have to go and fetch it from
Smyrna, to which, of course, moreover, there were none but sailing
ships. She said they never knew how long it would take, especially
because of the quarantine. Plague raged at Constantinople and
Jerusalem, so that vessels were often and often kept six weeks with
passengers in quarantine. She says the last plague was in 1843.... We
went to the House of Deputies to hear a debate, in the box of the
Diplomatic Corps, and could see well, and could have heard had we
known more Greek. It was very curiously interesting to see the
House. The gallery is open to the public, and was quite densely
packed with a crowd of the very poorest people, with earnest, eager
eyes, watching and listening, with an intentness beyond what I ever
saw at the play. Crowds outside, too, were standing, talking and
waiting; and this goes on day after day. Mr. Darcy, the clergyman
here, took us; and he knew all the members, and pointed them out to
us and told us about them. I have been reading some very interesting
statistics about Greece, published seven or eight years ago. Do you
know that since the independence her population has doubled, and
her revenue has increased 500 per cent.?—the children in school
were between 6,000 and 7,000 and are now 81,000. I forget the
increase of acres cultivated, but it is very large.

THE GROWTH OF
THE GREEK
Athens,
NATION April 8th, 1880.

To Miranda.

We went yesterday to Phyle, and saw the actual fortified place held
by Thrasybulus against the 30 tyrants. The gigantic walls still stand.
We went with Miss Muir, who is so friendly and delightful with all
the people, it is beautiful to see. It reminds me of going about with
Miss Cons. She always finds out all about the people and finds
helpful things to do for them; and it makes one see all the gentle,
helpful, friendly, hospitable side. It is so different from going about
with guides. We had such a glorious day. We drove for 10 miles over
a very bad road to a village called Chassia, quite up in a ravine of
Parnes. There the road stopped, and I had a mule, and we went for
2½ hours into the folds of the mountain ravines, till we came to the
great promontory-like rock. The utter solitude, the exquisite blue of
the shadows on the gigantic cliff-like rocks, the clear sun-filled air,
the fresh breeze, the far away look of plain or hill or bay alive with
noble memories filled me with a strange awed joy. I am much
touched with the nation. I am afraid I shall never tell you all that
makes me feel towards them as I do. I am getting such a vivid
impression of the people, its hopes and admirations, and capacities.
It is clearly growing. I have been reading a great many official
statistics, which show the wonderful growth. I cannot but believe it
has a great future. I sometimes think of Matthew Arnold’s ideas
about Hellenism, and wonder whether in very deed the people may
be destined to bring out that side of human nature he speaks of as so
wanting in the “Hebrew”;—the sort of intellectual grasp and
reverence for thought and intangible things. Yet the nation has hard
work just now with its tangible things, and is working to get them
into order. Also it has, in its suffering under the Turks, clung with
tenacity to its Christian faith, which is more than life to it; and this
feeling is intensified by the faith being connected with the nation, the
early martyrs for national freedom being many of them bishops. We
were present in the metropolitan church at the anniversary of Greek
independence. The king and the children were there. It was strange
to see the tremendous crowd, the solitary Lutheran king, the tiny
children standing between him and the people crossing themselves,
and the gorgeously dressed priests who seem so human and so near
the people compared with the Catholic clergy. With respect to the
national worship for an idea—THE families who are considered great
here are those who have lost their all at Missolonghi, or in supplying
ships from Hydra!

Athens,
April 8th, 1880.

To her Mother.

... How delighted you will be about the elections! Is it not really
marvellous; I never expected it! It is strange sometimes how silent
England is, and yet how her heart rings true! I am filled with
prayerful, almost tremulous, hope that the new Government will live
up to a high standard. Oh! do you think it will? It is pathetic to see
how happy the Greeks are about it, and how much they hope from
England now. Sometimes I fear the Liberals will not have courage to
tax to meet past expenditure quickly, as they ought; or to deal
generously with the little struggling nationalities. Those I shall feel
the test questions for them, as to their consciences. I believe they will
deal with the question of land, which will be good. The Barnetts are
here, and Mr. B. very much interested about the elections in
England.... Mr. B.’s whole heart is at home, and in talking of it....

COURTESY OF
GREEK
Corinth,
WORKMEN Sunday, April 11th, 1880.

To Her Mother.
We started on our travels again yesterday, and seem to have seen a
great deal. We drove from Athens to Megara yesterday—we being
Miss Yorke, Miss Muir, a very nice Swiss lady, and myself. We were
received and entertained by a hand-loom weaver, who knew Miss
Muir. They were so kind; they gave up to us a large room, their best,
and all slept in their second room, which led thro’ ours. Our beds
were spotlessly clean, but laid on the earthen floor, after we had all
had supper together, father, mother, married son and his wife, and
half the village looking on. I never saw more affectionate welcome, or
more native courtesy than they all showed. The son and his young
wife spent the afternoon taking us to call on their friends and
relations. It was so touching and beautiful; the very poorest people
receiving us with such a dignified bearing; and everywhere we had to
take something. One old woman, the mother of 12 children, and
quite poor, was quite distressed she had nothing but some figs and
nuts to give us. She remembered the time of the Turks and the
dreadful hardships. Our host had come out of Thessaly to be in “free
Greece,” after it was known that Thessaly was not to belong to
Greece. “Oh”! he said, “they brought the children away in boxes, or
anything, to get them safe into Greece.”
Megara is a populous village, almost entirely composed of houses
of one room only. The people wear the most lovely costume, and
carry themselves magnificently, so that every group forms a picture.
There was nothing pretty in the old houses, so I am glad to hear they
were beginning to build themselves better ones. We saw more of
their life than we could have seen anyhow else, and heard more of
their sayings. I shall just jot down a few, anyhow, to be sure to tell
you. They never speak harm of anything, especially in the evening.
They call the worst bit of a road Kali Scali, Kali meaning good; and in
the evening they respectfully call vinegar “the little sweet thing.”
Many of their expressions are formed from agricultural work. When
Miss Muir’s glove was lost they were much distressed, and said
someone must have “reaped” it. The bride and bridegroom are
married in crowns which are framed and hung up; and when they die
they are buried in them. The sons have to marry in regular order of
age, and must not do so till their sisters are married off. The boys and
girls—mere children—never stand together; the most eager crowds of
lookers-on yesterday sorted themselves, the boys being on one side,
and the girls on the other. They speak very freely to those above them
in rank, our host kept addressing Miss Muir: “Oh, sister, what sayest
thou?” tho’ the you is well distinguished from “thou.” There is no
water in the village, but a large washing place outside it—great stone
troughs by the spring; every girl, when she marries, has to receive
one as part of her dowry. The unmarried girls wear a complete skull-
cap made of half drachmas, about sixpence each; they never wear the
cap after marriage, and never unthread it for use, unless in dire need.
These people gave us food, lodging, and all their time, and turned out
of their room, and would not hear of receiving anything. As we came
along to-day, we met a flock of sheep with lambs; and Miss M. heard
the muleteers tell the shepherd to wait till they came back, as they
must take the Paschal lamb back for our host’s family. So we united
to send the lamb back as a present. The people are all rigidly fasting;
their Lent is not over. Not a man will touch any meat we offer him. At
Easter every family buys a lamb, fattens and kills it. We had a sort of
royal reception; the priest, the demarch, the schoolmaster, and all
the people coming down. Here we four, utter strangers, rode up
dusty and tired, sent in to the banker here a letter of introduction for
Mr. Dufour, and all four were instantly received, lodged, and fed as a
matter of course.

GREEK EASTER
FEASTS
Patras,
April 12th, 1880.

We came on by the Greek steamer here yesterday. Mr. Barnett


brought me from Athens your delightful letter and dear Miranda’s,
and some newspapers.... We have seen the Consul and his wife—
delightful people. They have recommended us a former servant of
their own, who was with them for years, to drive us to Olympia. The
same man lately took Mr. Newton, the chief man at the British
Museum. It is a four days’ drive there and back, and Miss Muir and
Mr. Dufour left us at Corinth, so we are thoroughly glad to have a
trustworthy man. We are in high spirits, the weather glorious; and
we are looking forward to going very much. Part of to-day’s drive is
thro’ four hours of oak forest! I do not know if we told you about
Olympia. The Germans are excavating there, and have found all the
temples buried under sand brought down by the Alpheus, and some
grand statues, one of Hermes, as fine as any of the world-famous
statues. It is very fine of the German Government to take all the
expense. They spent 10,000 francs annually on it till this year, when
they are too poor; and the Emperor himself has given 5,000 that the
work may not cease. Yet they are to have nothing for it except the
right of taking casts. Everything they find is to belong to the Greek
Government; only they stipulated that the Greeks should make them
a road. Scientific Germans are there directing, with 500 Greek
workmen. They say they are such splendid workmen, better than
Germans—so the director says. We take all our food with us to-day,
and sleep at a khan. At Olympia the director’s cook will take us in. It
is all very funny. Here there is a very nice hotel. We find our Greek
most useful. I am so delighted about the English news of elections.

Pyrgos,
April 14th, 1880.

To her Mother.

AN OAK WOOD IN I seem to have such a number of things to


GREECE
tell you, I hardly know how to begin. We left
Patras at 6 o’clock on Monday morning, and drove on and on for
miles, along the bright sea-shore, just on the beach; then we turned
inland, along the roughest roads; no boundary road in a remote
district in England could be worse. We had to go at a foot’s pace; but
it was all lovely, great masses of asphodel in full bloom, bushes of
broom one sheet of gold, crimson carpets of great cranesbill; olive,
oak, and terebinth; and between, and over them, we saw the bright
sea and the blue mountains. We drove thro’ countless streams, large
and small, now fording rivers, now plunging down steep banks. Then
we came to the oak forest thro’ which we drove, incessantly, over the
smooth turf, or gravelly soil, for four hours. The oaks stand, not close
together, but as in an English park, here and there, thicker or more
scattered, on slopes, or spaces of turf. Many of the trees were old and
knotted; some had suffered by fire; here and there were parts full of
rich underwood; and then we came to smooth sheets of delicate blue
with the tiny iris; the mountains were always in sight. There was
hardly a trace of cultivation; hardly a house the whole day to be seen;
and we drove incessantly till 6 at night. We stayed the night at a
khan, they say one of the best in Greece; and the wall and beds were
clean; but it is a strange kind of savage accommodation. The dogs
barked so, and the wind howled over the great plain we had reached;
I could not sleep much. Next day—yesterday—we started at 5 in the
morning, having cooked and eaten our breakfast. The clouds, which
had gathered over night, broke away before the sun; and we had a
magnificent day. We drove on and on, thro’ uncultivated wastes
rather like our heaths, thro’ water courses, and usually off the road, it
was so bad; but with the most splendid light, and a view of the sea,
and Zante in the distance. At mid-day we dined here; and then drove
on to Olympia in a sunlight I never shall forget. The road from here
to Olympia is very good. It has been made by the Greek Government,
that being the one condition the Germans made on undertaking the
excavations. We excited the greatest amazement, as no ladies do
anything alone here; it is very amusing. The country is much more
cultivated near here; and, going to Olympia, we saw several villages;
but still it was very strange to drive for 3½ hours up, as it were, into
the heart of an untraversed country, and find the road stopping in
the heart of a remote valley, where a handful of Germans had
undertaken this curious great work. Five hundred Greek workmen
were digging and carting and shovelling. Our coachman led us to a
sort of foreman, who asked us if we spoke German or Greek. He
spoke no English, but some Italian. We asked for a lodging, and he
sent one of his men to take us to the cottage of the director’s cook,
who has 3 spare rooms. We climbed a steep hill overlooking the
excavations, on which stood one new, well-built house. We were led
to such a cottage that I felt as if we hardly could sleep there. However
the bed was clean, and the view something splendid. We ate our
dinner laid on a board on the top of a stool; and we sat on the bed.
We had not an atom of blind, nor a chair!—After that we got a man
with a lantern; and, armed with one of Mrs. Coupland’s
introductions, a visiting card, and the name of a Dr. and Mrs. Irvi,
mentioned to us by the Consul at Patras, we went off to what the
peasants call the “German house.”—I had hardly sent in my card with
message of enquiry before Mrs. Irvi came out with kindest words and
hurried us in to a room where sat, after their dinner, the little
company of Germans, who are directing the work. She introduced us
to Herr Kurtzius, who speaks English. Such a man! but I must tell
you of him later. Mrs. I. was so kind, would make us have coffee and
stay, and would go back with us to see where we were lodged. She
laughed, saying, “Oh yes! its our very best hotel here, you could not
do better.” Three gentlemen friends of theirs were sleeping there too.
The German house is quite full.—We breakfasted with the Irvis at 7
o’clock, and then Herr K. came with his plan, and for three hours
shewed us over the excavations. He is such a man! It has evidently
GERMAN been the dream of his life to do this thing; and
EXCAVATIONS AT now it is nearly done. You can see by the far
OLYMPIA
away look of his great blue eyes, and the way
he stumbles over the wood and stones in his path, that his thoughts
are of the past and the future, or, at any rate, not of the earth, earthy.
It was he who imagined doing this thing, mentioned it to the Crown
Prince, who got the German Parliament to pay; and now they have
excavated, at a depth of often 20 feet of gravel, the whole space on
which the temples and their surrounding buildings stood. The space
occupied is that bounded on the south by the Alpheus, just where a
smaller river joins it. This triangular space lies at the foot of a small
sand hill. But such a valley as it is! And between the mountains that
bound it you can see the opening to the defiles leading south to
Messina, north to Corinth, east to Sparta; and all round the wooded
hills look down upon the sunny plain, and you can almost see the old
Greeks trooping in from every quarter. The foundations of all the
buildings are found, the bases of walls and pillars in their places, the
steps, the entrances, the pedestals of the statues all in their places.
Twenty-one statues (or the principal part of them) from the
pediments have been found, besides the Hermes and Bacchus of
Praxiteles, and numbers of Roman statues, and a lovely Greek figure
of the Winged Victory descending. The Hermes is splendid. He
carries the infant Bacchus on his arm, such a sweet child; the head
was only found last week. The early statues from the pediment are
very powerful, massive and expressive, but not so delicate nor so
exquisitely true in artistic power. I almost think the whole scene
impressed me most. The great temple of Zeus stands in the centre of
the ground, its mighty pillars shattered by earthquake. One sees the
pedestal of the gold figure of Zeus sixty feet high, which was taken
from Byzantium; one sees all round the other temples. The one to
Hera is one of the oldest. Pelops has a temple too; but, being a hero
who died, not a god who lives always, its entrance is to the setting
sun, not on the East like those of the rest. Then there is the
Gymnasium, where the youths practised with the rough stones, that
they might not slip in wrestling, and the smooth ones for their
masters still lying in their places. Beyond are the eleven treasure
houses, built by eleven of the Greek towns, each for their own votive
offerings to the gods, which on great feast days were opened and
their glories displayed. Then I was interested to see the one that
belonged to Megara. There is a great arched passage, leading from
the space where the altars were, thro’ which, after sacrificing to the
gods, the judges and competitors in solemn procession walked, not
being visible to the people assembled to see the games, till they came
out of the passage. Two statues, one of Fortune and one of Nemesis,
were found, which watched over this way—the one supposed to
remind competitors how Fortune might favour or injure them, the
other to warn the judges and competitors alike of the punishment
which certainly overtakes any breach of fairness. We saw the stone
from which the runners started; and, exactly 600 feet beyond, where
they knew it ought to be, these Germans dug down twenty-one feet
thro’ the gravel, and found the goal or opposite starting place. We
saw the men washing tiny little bronze figures of animals about one
and a half inches long, which they had just found, which are
supposed to be votive offerings from the very poor to the god. They
are green with age now.
HERR KURTZIUS These Germans leave in a month or two;
and the 500 men cease working. They will be dreadfully missed; for
they have brought work and money, and civilisation and visitors,
right up into the heart of the country. The place will be left—the
Greek Pompeii—to the Greeks to take care of. They have to build a
museum and arrange the treasures. Herr Kurtzius carries away all he
has learned. He has sent to Berlin the casts and plans and maps; and
there they are making models of the thing as he found it, and as he
thinks it was of old. He takes, one may say—nothing; but one sees
that to him to have done what enables him to know is all. He doesn’t
look as if he worked for fame, or for others, but to know and to see.
As he showed us the things, now and then he flashed up, as if it were
all before him, and spoke of the life that had been as if he saw,
sometimes gently stroked the faces of the statues, pointing out how
perfect they were; now and again his eyes looked out as to some
further thought he did not tell.
We post this at Patras, where we arrived safely to-night (April
16th); to-morrow we go by steamer to Athens, where I hope to find
news of you all.

Achmetaga, Eubœa,
April 24th, 1880.

Octavia to her Mother.

... I must try to tell you something of all we have been seeing. We
left Athens on Tuesday at five o’clock in the morning, having engaged
a carriage to take us to Thebes. It was an exquisite morning, and we
drove by Eleusis thro’ a pass of Cithæron, supposed to be that of
Eleuthera. We saw the ruins of the fortress of the ancient Greeks
guarding the Attic end of the pass. As we came down on the Bœotian
side, a magnificent view of Parnassus opened on our left; the site of
Platæa was in sight; but nothing remains to mark it, as seen from a
distance; far away to the East we saw the grand snow-covered range
of mountains in Eubœa, and the beautiful peak of Delphi (Delphi in

You might also like