Full download Javascript info Ebook Part 2 Browser Document Events Interfaces 1st Edition Ilya Kantor pdf docx
Full download Javascript info Ebook Part 2 Browser Document Events Interfaces 1st Edition Ilya Kantor pdf docx
com
https://textbookfull.com/product/javascript-info-ebook-
part-2-browser-document-events-interfaces-1st-edition-ilya-
kantor/
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/javascript-info-ebook-part-1-the-
javascript-language-1st-edition-ilya-kantor/
textboxfull.com
https://textbookfull.com/product/javascript-info-ebook-
part-3-additional-articles-1st-edition-ilya-kantor/
textboxfull.com
https://textbookfull.com/product/dom-scripting-web-design-with-
javascript-and-the-document-object-model-keith-jeremy-sambells-
jeffrey/
textboxfull.com
https://textbookfull.com/product/brain-computer-
interfaces-2-technology-and-applications-1st-edition-maureen-clerc/
textboxfull.com
Beginning Machine Learning in the Browser Quick start
Guide to Gait Analysis with JavaScript and TensorFlow js
1st Edition Nagender Kumar Suryadevara
https://textbookfull.com/product/beginning-machine-learning-in-the-
browser-quick-start-guide-to-gait-analysis-with-javascript-and-
tensorflow-js-1st-edition-nagender-kumar-suryadevara/
textboxfull.com
https://textbookfull.com/product/on-art-ilya-kabakov/
textboxfull.com
https://textbookfull.com/product/barbecue-sauces-rubs-and-marinades-
bastes-butters-glazes-too-ebook-biblioboard-2-ed-edition-raichlen/
textboxfull.com
https://textbookfull.com/product/beginning-machine-learning-in-the-
browser-1st-edition-nagender-kumar-suryadevara/
textboxfull.com
Part 2
Browser: Document,
Events, Interfaces
Ilya Kantor
Built at July 10, 2019
The last version of the tutorial is at https://javascript.info.
We constantly work to improve the tutorial. If you find any mistakes, please write
at our github.
● Document
● Browser environment, specs
●
DOM tree
●
Walking the DOM
● Searching: getElement*, querySelector*
● Node properties: type, tag and contents
● Attributes and properties
● Modifying the document
● Styles and classes
● Element size and scrolling
● Window sizes and scrolling
● Coordinates
● Introduction to Events
● Introduction to browser events
● Bubbling and capturing
● Event delegation
● Browser default actions
● Dispatching custom events
● UI Events
● Mouse events basics
● Moving: mouseover/out, mouseenter/leave
● Drag'n'Drop with mouse events
●
Keyboard: keydown and keyup
● Scrolling
● Forms, controls
● Form properties and methods
● Focusing: focus/blur
●
Events: change, input, cut, copy, paste
● Forms: event and method submit
● Document and resource loading
● Page: DOMContentLoaded, load, beforeunload, unload
● Scripts: async, defer
● Resource loading: onload and onerror
● Miscellaneous
● Mutation observer
●
Selection and Range
● Event loop: microtasks and macrotasks
Learning how to manage the browser page: add elements, manipulate their size
and position, dynamically create interfaces and interact with the visitor.
Document
Here we’ll learn to manipulate a web-page using JavaScript.
function sayHi() {
alert("Hello");
}
There are more window-specific methods and properties, we’ll cover them later.
The document object gives access to the page content. We can change or
create anything on the page using it.
For instance:
CSSOM is used together with DOM when we modify style rules for the
document. In practice though, CSSOM is rarely required, because usually
CSS rules are static. We rarely need to add/remove CSS rules from
JavaScript, so we won’t cover it right now.
Browser Object Model (BOM) are additional objects provided by the browser (host
environment) to work with everything except the document.
For instance:
●
The navigator object provides background information about the browser
and the operating system. There are many properties, but the two most widely
known are: navigator.userAgent – about the current browser, and
navigator.platform – about the platform (can help to differ between
Windows/Linux/Mac etc).
●
The location object allows us to read the current URL and can redirect the
browser to a new one.
Summary
DOM specification
Describes the document structure, manipulations and events, see
https://dom.spec.whatwg.org .
CSSOM specification
Describes stylesheets and style rules, manipulations with them and their binding
to documents, see https://www.w3.org/TR/cssom-1/ .
HTML specification
Describes the HTML language (e.g. tags) and also the BOM (browser object
model) – various browser functions: setTimeout , alert , location and so
on, see https://html.spec.whatwg.org . It takes the DOM specification and
extends it with many additional properties and methods.
Please note these links, as there’s so much stuff to learn it’s impossible to cover
and remember everything.
When you’d like to read about a property or a method, the Mozilla manual at
https://developer.mozilla.org/en-US/search is also a nice resource, but the
corresponding spec may be better: it’s more complex and longer to read, but will
make your fundamental knowledge sound and complete.
Now we’ll get down to learning DOM, because the document plays the central role
in the UI.
DOM tree
The backbone of an HTML document are tags.
According to Document Object Model (DOM), every HTML-tag is an object.
Nested tags are called “children” of the enclosing one.
The text inside a tag it is an object as well.
An example of DOM
<!DOCTYPE HTML>
<html>
<head>
<title>About elks</title>
</head>
<body>
The truth about elks.
</body>
</html>
The DOM represents HTML as a tree structure of tags. Here’s how it looks:
▾ HTML
▾ HEAD
#text ↵␣␣␣␣
▾ TITLE
#text About elks
#text ↵␣␣
#text ↵␣␣
▾ BODY
#text The truth about elks.
Tags are called element nodes (or just elements). Nested tags become children of
the enclosing ones. As a result we have a tree of elements: <html> is at the
root, then <head> and <body> are its children, etc.
The text inside elements forms text nodes, labelled as #text . A text node
contains only a string. It may not have children and is always a leaf of the tree.
For instance, the <title> tag has the text "About elks" .
Please note the special characters in text nodes:
● a newline: ↵ (in JavaScript known as \n )
●
a space: ␣
Spaces and newlines – are totally valid characters, they form text nodes and
become a part of the DOM. So, for instance, in the example above the <head>
tag contains some spaces before <title> , and that text becomes a #text
node (it contains a newline and some spaces only).
There are only two top-level exclusions:
1. Spaces and newlines before <head> are ignored for historical reasons,
2. If we put something after </body> , then that is automatically moved inside
the body , at the end, as the HTML spec requires that all content must be
inside <body> . So there may be no spaces after </body> .
In other cases everything’s straightforward – if there are spaces (just like any
character) in the document, then they become text nodes in DOM, and if we
remove them, then there won’t be any.
<!DOCTYPE HTML>
<html><head><title>About elks</title></head><body>The truth about elks.</body></h
▾ HTML
▾ HEAD
▾ TITLE
#text About elks
▾ BODY
#text The truth about elks.
Edge spaces and in-between empty text are usually hidden in tools
Browser tools (to be covered soon) that work with DOM usually do not show
spaces at the start/end of the text and empty text nodes (line-breaks) between
tags.
That’s because they are mainly used to decorate HTML, and do not affect how
it is shown (in most cases).
On further DOM pictures we’ll sometimes omit them where they are irrelevant,
to keep things short.
Autocorrection
For instance, the top tag is always <html> . Even if it doesn’t exist in the
document – it will exist in the DOM, the browser will create it. The same goes for
<body> .
As an example, if the HTML file is a single word "Hello" , the browser will wrap
it into <html> and <body> , add the required <head> , and the DOM will be:
▾ HTML
▾ HEAD
▾ BODY
#text Hello
<p>Hello
<li>Mom
<li>and
<li>Dad
…Will become a normal DOM, as the browser reads tags and restores the
missing parts:
▾ HTML
▾ HEAD
▾ BODY
▾P
#text Hello
▾ LI
#text Mom
▾ LI
#text and
▾ LI
#text Dad
<table id="table"><tr><td>1</td></tr></table>
▾ TABLE
▾ TBODY
▾ TR
▾ TD
#text 1
You see? The <tbody> appeared out of nowhere. You should keep this in
mind while working with tables to avoid surprises.
<!DOCTYPE HTML>
<html>
<body>
The truth about elks.
<ol>
<li>An elk is a smart</li>
<!-- comment -->
<li>...and cunning animal!</li>
</ol>
</body>
</html>
▾ HTML
▾ HEAD
▾ BODY
#text The truth about elks.
▾ OL
#text ↵␣␣␣␣␣␣
▾ LI
#text An elk is a smart
#text ↵␣␣␣␣␣␣
#comment comment
#text ↵␣␣␣␣␣␣
▾ LI
#text ...and cunning animal!
#text ↵␣␣␣␣
#text ↵␣␣↵
Here we see a new tree node type – comment node, labeled as #comment .
We may think – why is a comment added to the DOM? It doesn’t affect the visual
representation in any way. But there’s a rule – if something’s in HTML, then it also
must be in the DOM tree.
Everything in HTML, even comments, becomes a part of the DOM.
Even the <!DOCTYPE...> directive at the very beginning of HTML is also a
DOM node. It’s in the DOM tree right before <html> . We are not going to touch
that node, we even don’t draw it on diagrams for that reason, but it’s there.
The document object that represents the whole document is, formally, a DOM
node as well.
To see the DOM structure in real-time, try Live DOM Viewer . Just type in the
document, and it will show up DOM at an instant.
Another way to explore the DOM is to use the browser developer tools. Actually,
that’s what we use when developing.
To do so, open the web-page elks.html, turn on the browser developer tools and
switch to the Elements tab.
It should look like this:
You can see the DOM, click on elements, see their details and so on.
Please note that the DOM structure in developer tools is simplified. Text nodes are
shown just as text. And there are no “blank” (space only) text nodes at all. That’s
fine, because most of the time we are interested in element nodes.
Clicking the button in the left-upper corner allows to choose a node from the
webpage using a mouse (or other pointer devices) and “inspect” it (scroll to it in
the Elements tab). This works great when we have a huge HTML page (and
corresponding huge DOM) and would like to see the place of a particular element
in it.
Another way to do it would be just right-clicking on a webpage and selecting
“Inspect” in the context menu.
At the right part of the tools there are the following subtabs:
● Styles – we can see CSS applied to the current element rule by rule, including
built-in rules (gray). Almost everything can be edited in-place, including the
dimensions/margins/paddings of the box below.
●
Computed – to see CSS applied to the element by property: for each property
we can see a rule that gives it (including CSS inheritance and such).
●
Event Listeners – to see event listeners attached to DOM elements (we’ll
cover them in the next part of the tutorial).
● …and so on.
The best way to study them is to click around. Most values are editable in-place.
As we explore the DOM, we also may want to apply JavaScript to it. Like: get a
node and run some code to modify it, to see the result. Here are few tips to travel
between the Elements tab and the console.
●
Select the first <li> in the Elements tab.
●
Press Esc – it will open console right below the Elements tab.
From the other side, if we’re in console and have a variable referencing a DOM
node, then we can use the command inspect(node) to see it in the Elements
pane.
Or we can just output it in the console and explore “at-place”, like
document.body below:
That’s for debugging purposes of course. From the next chapter on we’ll access
and modify DOM using JavaScript.
The browser developer tools are a great help in development: we can explore the
DOM, try things and see what goes wrong.
Summary
<html> = document.documentElement
The topmost document node is document.documentElement . That’s DOM
node of <html> tag.
<body> = document.body
Another widely used DOM node is the <body> element – document.body .
<head> = document.head
The <head> tag is available as document.head .
A script cannot access an element that doesn’t exist at the moment of running.
In particular, if a script is inside <head> , then document.body is
unavailable, because the browser did not read it yet.
So, in the example below the first alert shows null :
<html>
<head>
<script>
alert( "From HEAD: " + document.body ); // null, there's no <body> yet
</script>
</head>
<body>
<script>
alert( "From BODY: " + document.body ); // HTMLBodyElement, now it exists
</script>
</body>
</html>
In the DOM, the null value means “doesn’t exist” or “no such node”.
There are two terms that we’ll use from now on:
●
Child nodes (or children) – elements that are direct children. In other words,
they are nested exactly in the given one. For instance, <head> and <body>
are children of <html> element.
●
Descendants – all elements that are nested in the given one, including
children, their children and so on.
For instance, here <body> has children <div> and <ul> (and few blank text
nodes):
<html>
<body>
<div>Begin</div>
<ul>
<li>
<b>Information</b>
</li>
</ul>
</body>
</html>
…And all descendants of <body> are not only direct children <div> , <ul> but
also more deeply nested elements, such as <li> (a child of <ul> ) and <b> (a
child of <li> ) – the entire subtree.
<html>
<body>
<div>Begin</div>
<ul>
<li>Information</li>
</ul>
<div>End</div>
<script>
for (let i = 0; i < document.body.childNodes.length; i++) {
alert( document.body.childNodes[i] ); // Text, DIV, Text, UL, ..., SCRIPT
}
</script>
...more stuff...
</body>
</html>
Please note an interesting detail here. If we run the example above, the last
element shown is <script> . In fact, the document has more stuff below, but at
the moment of the script execution the browser did not read it yet, so the script
doesn’t see it.
Properties firstChild and lastChild give fast access to the first and
last children.
They are just shorthands. If there exist child nodes, then the following is always
true:
DOM collections
As we can see, childNodes looks like an array. But actually it’s not an array,
but rather a collection – a special array-like iterable object.
There are two important consequences:
The first thing is nice. The second is tolerable, because we can use
Array.from to create a “real” array from the collection, if we want array
methods:
Changing DOM needs other methods. We will see them in the next chapter.
Please, don’t. The for..in loop iterates over all enumerable properties.
And collections have some “extra” rarely used properties that we usually do
not want to get:
<body>
<script>
// shows 0, 1, length, item, values and more.
for (let prop in document.body.childNodes) alert(prop);
</script>
</body>
Siblings are nodes that are children of the same parent. For instance, <head>
and <body> are siblings:
●
<body> is said to be the “next” or “right” sibling of <head> ,
● <head> is said to be the “previous” or “left” sibling of <body> .
For instance:
<html><head></head><body><script>
// HTML is "dense" to evade extra "blank" text nodes.
Element-only navigation
The links are similar to those given above, just with Element word inside:
● children – only those children that are element nodes.
●
firstElementChild , lastElementChild – first and last element
children.
●
previousElementSibling , nextElementSibling – neighbour
elements.
● parentElement – parent element.
This loop travels up from an arbitrary element elem to <html> , but not to
the document :
while(elem = elem.parentElement) {
alert( elem ); // parent chain till <html>
}
Let’s modify one of the examples above: replace childNodes with children .
Now it shows only elements:
<html>
<body>
<div>Begin</div>
<ul>
<li>Information</li>
</ul>
<div>End</div>
<script>
for (let elem of document.body.children) {
alert(elem); // DIV, UL, DIV, SCRIPT
}
</script>
...
</body>
</html>
<tr> :
● tr.cells – the collection of <td> and <th> cells inside the given <tr> .
● tr.sectionRowIndex – the position (index) of the given <tr> inside the
enclosing <thead>/<tbody>/<tfoot> .
● tr.rowIndex – the number of the <tr> in the table as a whole (including
all table rows).
An example of usage:
<table id="table">
<tr>
<td>one</td><td>two</td>
</tr>
<tr>
<td>three</td><td>four</td>
</tr>
</table>
<script>
// get the content of the first row, second cell
alert( table.rows[0].cells[1].innerHTML ) // "two"
</script>
There are also additional navigation properties for HTML forms. We’ll look at them
later when we start working with forms.
Summary
Given a DOM node, we can go to its immediate neighbours using navigation
properties.
There are two main sets of them:
● For all nodes: parentNode , childNodes , firstChild , lastChild ,
previousSibling , nextSibling .
●
For element nodes only: parentElement , children ,
firstElementChild , lastElementChild ,
previousElementSibling , nextElementSibling .
Some types of DOM elements, e.g. tables, provide additional properties and
collections to access their content.
✔ Tasks
DOM children
importance: 5
<html>
<body>
<div>Users:</div>
<ul>
<li>John</li>
<li>Pete</li>
</ul>
</body>
</html>
How to access:
To solution
To solution
You’ll need to get all diagonal <td> from the <table> and paint them using the
code:
To solution
document.getElementById or just id
If an element has the id attribute, then there’s a global variable by the name
from that id .
<div id="elem">
<div id="elem-content">Element</div>
</div>
<script>
alert(elem); // DOM-element with id="elem"
alert(window.elem); // accessing global variable like this also works
<div id="elem"></div>
<script>
let elem = 5;
alert(elem); // 5
</script>
For instance:
<div id="elem">
<div id="elem-content">Element</div>
</div>
<script>
let elem = document.getElementById('elem');
elem.style.background = 'red';
</script>
Here in the tutorial we’ll often use id to directly reference an element, but that’s
only to keep things short. In real life document.getElementById is the
preferred method.
If there are multiple elements with the same id , then the behavior of
corresponding methods is unpredictable. The browser may return any of them
at random. So please stick to the rule and keep id unique.
Exploring the Variety of Random
Documents with Different Content
THE SHRINE OF BIBI ANNA.
Page 93.
Try as I would, I was unable to gain any information about the Bibi
Khanum, as she was called. The white flag brought her often to my
mind, as I could not stand upon the garden-terrace without seeing it,
and now and again at night I observed a lighted lamp hanging above
her last resting-place. In a Mohamedan country where woman in
theory is little regarded, what had the Lady Anna done that a shrine
at which miracles were reputed to be performed should be erected to
her memory? When did she live? Was she perhaps kin to Hazrat
Apak the Priest-King of Kashgar? I can answer none of these
questions, and merely know that she was regarded with much
veneration.
On one occasion, when many women were assembled at her grave,
I asked some of them to put their hands into the holes of the tomb
and allow me to photograph them in that position, but realized at
once how tactless I had been. With shocked faces the women
explained that such a thing would practically amount to sacrilege; but
they had no objection to being photographed seated beside the
mazzar.
Perhaps the most popular shrine is that of Ali Arslan, a couple of
miles to the north of the city, the road leading up to it being bordered
on either side by gardens, the property of the mazzar and a great
holiday resort. The lofty brick gateway is barred to horses and
vehicles by a tree-trunk, over which we clambered, to find ourselves
in a large enclosure with a great tank of water planted round with
stately poplars, a usual and pleasing characteristic of holy places in
Chinese Turkestan. Behind it lay the shrine, an insignificant building
entered by an old carved and fretted doorway, one of the best
specimens of this form of native art that we came across in the
country. An old akhun—his office is to read the Koran at the graves
for the benefit of the departed—was kneeling and reciting prayers
before it, and inside the small space was filled by a large tomb
covered with blue and white tiles, trophies of flags, and horns of the
wild sheep.
Sultan Arslan Boghra, the hero-saint, surnamed the Tiger for his
bravery, who is honoured here, fought with great valour against the
Buddhist inhabitants of Khotan, who did not wish to change their
religion for the tenets of Islam. He was one of the earliest
Mohamedan conquerors of Kashgar, and it is recorded by Bellew
that the pagan ruler of Khotan, who led his force against the
Moslems, offered a large reward to the man who could compass the
Sultan’s death. At this time the Nestorian Church had its adherents
throughout Asia, and the story runs that one of its priests counselled
the Buddhists to fall upon their opponents at dawn, as they would
then be engaged with their devotions and so would be taken
unawares. The advice was followed, and in a great battle on the
desert plain of Ordam-Padshah, some fifty miles south-east of
Kashgar, the adherents of the Prophet were utterly routed and their
gallant leader slain.
Ali Arslan’s head was carried in triumph round the walls of Kashgar,
into which the Moslems had retreated for the time, and it is supposed
to be buried in the shrine that we visited. His body, however, rests at
Ordam-Padshah, and Sir Aurel Stein writes that a mound covered
with poplars from which flutter rags is all that marks the grave of the
saint, although it is a peculiarly holy spot and is annually visited by
hundreds of pilgrims.
There are various shrines outside the city that claim to cure
particular diseases. A relative of Ali Arslan is interred in one of these,
and before the fretted windows of his mazzar is an ancient willow
that leans over nearly to the ground. If a patient afflicted with
rheumatism will go round the tree seven times in a believing spirit,
bending nearly double in order to rub his back against the bark, it is
said that he will be freed from his complaint. Old Jafar Bai tried the
treatment one day when we were there, but I never ventured to
question him as to the result. The so-called Tombs of the Mongols
outside the city seemed to me to be somewhat of a fraud, as the
mud-domed graves were quite modern. But they are visited annually
by thousands of the Faithful, who gamble, feast and have a day’s
outing in the neglected cemetery, many, I was told, omitting to say
their prayers.
To turn to another subject, although Kashgar is the seat of
Government, the entrance of the yamen being marked by the masts,
some seventy feet high, and the grotesque stone lions that signify
authority, yet the Chinese troops are in barracks at Yangi Shahr
(New City) some six or seven miles distant. This town is surrounded
by high parapeted mud walls in good repair; two sally-ports have to
be passed before the big bazar can be entered, and, as is
customary, these entrances are crooked in order to foil the evil
spirits. Just inside the Pai-fang, or roofed gateway, there is a
Chinese temple, and over the gate a building in which paper prayers
are burnt on fête days and the ashes flung to the heavens.
The stalls in the bazar, with their wooden shutters and matting
awnings, seemed much the same as those in the Old City, but in
Yangi Shahr the Celestial was at home instead of looking like an
intruder, and soldiers in khaki uniforms and forage caps of German
appearance were everywhere to be seen. Black, the royal colour of
the Manchus, was still affected by the inhabitants, and most
unsuitable wear it was for such a dusty place, but the flag of the
Republic, with its five colours, flew over every yamen. It interested
me to hear that the yellow stripe stood for China, the black for the
Manchus, the red for the Mongols, the blue for Tibet, and the white
for the Moslem subjects.
The Chinese seem to hold the province more by bluff than by force,
the troops being few, of all ages, and not troubled by overmuch drill.
Certainly the Governor and the Commander-in-Chief always go forth
in considerable state with detonations of crackers in order to impress
the populace, but as, owing to Chinese arrogance, the officials
decline to learn any foreign language, they never get into touch with
the people they are supposed to govern. Being intensely proud of
their old civilization, they utterly decline to move with the times or
absorb new ideas, and so are, as it were, petrified.
The upper classes are brought up to despise manual labour and are
admirers of the pen, holding the sword in contempt, and as a result
are often incapable of defending themselves if attacked. Social
distinction goes by learning, a literatus being the equal of any one
and invariably accorded a seat of honour at the yamen. Probably
their unhealthy lives—for they take no exercise, love darkened
rooms and are addicted to drink and opium-smoking—have brought
them to this ignominious pass; and one Governor said that the long
nails he affected were an excellent aid to self-control, for he could
never clench his hand to strike any one in anger! They rule the
province easily, because the inhabitants are a mild unwarlike race,
accustomed for centuries to be under the heel of a conqueror and
preferring the tolerant domination of China to that of Russia.
Liu-Kin-tang, the general who reconquered the province after the
death of Yakub Beg, has a big temple erected to his honour outside
the New City, and one afternoon we made an expedition to see it. It
is just off the broad tree-planted road, always full of traffic, which is
spanned by imposing-looking painted bridges that cross the Kizil Su.
On our arrival we rode into a large courtyard, where we dismounted
to pass through a fantastically decorated gateway into a second
courtyard, and were met by the Governor of the City, whose robes of
black and blue were crowned by a panama hat. One of his
attendants wore a black felt “billy-cock” that looked oddly out of
keeping with the rest of his costume, as did the caricatures of
English straw hats that were affected by the others. The Governor
escorted us to the temple, the façade of which was a blaze of gold,
blue and scarlet mingled with Chinese inscriptions. The tomb of the
famous general was under a carved canopy, over which gilded
dragons careered, and before it was the hero’s portrait, an enlarged
coloured photograph. An old bronze tripod for burning joss-sticks,
and a great bronze bell that the Governor struck in order that we
might hear its wonderful tone, stood in front of the photograph, and
on one side of the tomb was a fresco of a black and white tiger.
Formerly there were large paintings on the walls depicting the
general’s career, but unluckily all these had been destroyed by a
recent earthquake, and the temple had practically been rebuilt and
was shorn of much of its original decoration.
I wondered whether Liu-Kin-tang at all resembled the general of an
amusing story told us by Sir Aurel Stein. This Chinaman set out with
an army of twelve thousand men to conquer an enemy that inhabited
a very hilly country, and he was obliged to negotiate an extremely
difficult pass in order to get into touch with the foe. His soldiers
clambered to the crest of the ascent and, as he had foreseen, were
seized with fear and refused to go farther, but took heart of grace
when a body of the recalcitrant tribesmen came forward and
tendered their submission. In reality these were devoted followers of
the general, who had commanded them to disguise themselves, and
on their appearance the army, with its moral restored, streamed gaily
down the pass into what they imagined to be a conquered country.
And so in effect it was; for the tribesmen, terrified at the great host,
hastened to surrender, and thus fully justified the astute plan of the
general.
The priest in charge of the temple, clad in black and wearing a
curious cap, was a weird object, with long greasy hair standing out
from his face, and I did my best to reproduce his Cheshire-cat grin
with my kodak. When we had seen everything we were invited to
partake of tea, and seated ourselves at a small table covered with a
cloth badly in need of the wash. Our host put huge chunks of dingy-
looking sugar into our glasses with his fingers, and with the same
useful members helped us to little sponge cakes and thin biscuits
made of toffee and meal. He himself had the usual little china bowl in
which the tea is seethed; a small inverted bowl is placed on the top
to prevent the escape of the leaves, and the tea is drunk through the
crack between the two.
In common with most upper-class Chinese, the Governor looked ill
and had bad teeth, and certainly the fondness of Celestials for
turning night into day and carefully avoiding fresh air makes them
look very different from the robust Kashgaris, who are at their best
on horseback and are essentially an outdoor race. A Celestial is
proud of his half-inch-long finger-nails, which show that he has never
condescended to manual labour, and if he lives abroad he will send
his parents a packet of nail-parings in order to assure them that he is
one of the literati, who are treated with such consideration
throughout the Empire. When forced to travel a Chinaman will not
ride, but will go in a mapa. This is a painted cart having a blue and
black awning and a tasteful dash of scarlet at the back, on which a
charm is inscribed, and there are jingling bells on the horses to ward
off evil spirits. But the lower classes are very different; strong, hardy
and uncomplaining, and seeming to bear out the saying—“A
Chinaman is ill only once in his life, and that is when he is dying.”
There were not many Chinese women at Kashgar, and I was told
that the conquering race does not look upon any marriage as legal
unless it is contracted with a girl of their own country, whom they
practically buy. The amount that a would-be husband must pay for a
wife is fixed by go-betweens according to her looks and her position
in the world. When this is settled, the couple, clad in their best
clothes, enter a room where their friends are assembled, bow low to
each other, and then carry round a tray of bowls of tea, which they
offer to their guests. This ceremony completes the marriage, and
when the bridegroom has lived several days in the house of his
parents-in-law he takes his bride to his own home, where she is
henceforth under the rule of her mother-in-law.
Although according to English ideas the Chinaman makes but an
indifferent husband, he is very proud of his sons. The Celestials
carry the Oriental regard for the male sex to extremes. For example,
an Englishwoman who had lived in China told me that when she
bade her Chinese nurse chastise her little boy if naughty, the woman
looked at her in horror, saying in shocked tones, “Him piecee man—I
no touch piecee man!” I was told that parents like a boy to be
headstrong and uncontrolled, because they think that he is likely to
make his way in the world; and they are pleased if he steals
cunningly, saying to one another, “Our son is beginning to help the
house early.” Lying is a fine art among both Chinese and Kashgaris,
and there is little shame at being found out.
There is no need for a “Society for the Prevention of Cruelty to
Animals” among the Chinese, for they are trained to be considerate
to the “brute creation,”—a very pleasant trait in their characters.
They certainly live up to their own saying, “Be kind to the horse that
carries you, to the cow that feeds you and to the dog that guards
your possessions,” and they are an example to the Kashgaris, who
are callous if not actually cruel in their treatment of animals.
The frequently over-fat horses, mules and dogs belonging to
Celestials presented a strong contrast to the usually overworked and
underfed Kashgari donkeys, that were beaten by their owners on the
slightest provocation. And yet these little creatures, sometimes
almost hidden under piles of brushwood or staggering along under
loads of sun-dried bricks, or perhaps a plough, the handles of which
scraped the ground at every step, keep their independence
strangely. They do not obey the voice of their masters, as do the
horses; each donkey in a drove picks his own path and does not, like
the caravan ponies, follow a leader slavishly. Surely an animal so
strong and intelligent deserves a better fate than blows and semi-
starvation.
Every one who has travelled in Mohamedan countries knows that the
dog is looked upon as an unclean animal, and the starved and
mangy pariahs of Kashgar merely filled the position of town-
scavengers, though others that were kept to guard the houses were
somewhat better treated. These watch-dogs used to rush out and
leap at our horses in most unpleasant fashion, until my brother
taught them better manners with the lash of his hunting-crop.
Fortunately for the cat, the Prophet made a pet of this animal, and it
is therefore held in high favour.
At the end of May we had a most interesting visitor in the person of
Sir Aurel Stein, on his return from two years in the desert, where he
had made fresh discoveries of great importance and extent, his finds
filling a hundred and fifty packing-cases. Owing to the wonderful
preservative power of sand he had found some specimens of very
ancient paper, in connection with which Sir George Macartney drew
my attention to the following passage in Chavannes. The French
scholar wrote of two particular documents found by Sir Aurel Stein,
“qu’ils paraissent bien remonter au deuxième siècle de notre ère, et
sont ainsi les plus vieux spécimens de papier qu’il y ait au monde.”
Although Sir Aurel liked the Chinese so well, he said that he was
glad to return to Turkestan, where the inhabitants are most
hospitable and always ready to place houses and gardens at the
disposal of strangers. In fact they are so open-handed that they offer
food to any one who comes to the house at any hour; the well-to-do
apparently eating at short intervals all day long. But in China, with its
old civilization, the custom is very different, the people allowing no
one to enter their doors unless he be armed with introductions.
Fortunately, the gods are always ready to receive guests, and Sir
Aurel has spent many a night in temples full of hideous idols. Such
quarters, however, though pleasantly cool in summer, are icy cold in
winter.
Another thing that makes travelling in China disagreeable to
Europeans is that the inhabitants crowd round any stranger to
observe him. They consider that in so doing they are showing
attention, and the luckless man renders himself unpopular if he
resents it. This behaviour is in strong contrast to that of the Turki,
who are most polite, in the English manner, to travellers, and though
my brother and I rode and walked through the whole Oasis we never
once had a disagreeable look or word; in fact, the only curiosity
about us was shown by the women, and that in most unobtrusive
fashion.
CHAPTER VI
ON THE WAY TO THE RUSSIAN PAMIRS
This Central Asian scenery has a type of its own, quite different from the
Swiss or Caucasian mountain scenes....
Here, though the mountains are higher, the glaciers, owing to the small
snowfall, are much more puny, while below there is a picture of utter
desolation that would be hard to match in any other part of the world.—St.
George Littledale.
Though our baggage ponies were lightly laden they seemed at times
almost overwhelmed, but the Beg of Tashmalik and his men who
escorted us, knew the dreaded Gez River in all its moods, and
shepherded the terrified animals most cleverly. At the deepest fords
camels were called into requisition and with much querulous
complaining were forced into the stream with our loads, and on these
occasions the Beg insisted that I should mount his own horse, saying
that it was an expert at negotiating torrents. The lord of this district
was a big, ruddy-faced man, and could hardly take his eyes off the
first Englishwoman he had ever seen, being particularly interested in
my side-saddle, which he thought was a most insecure perch. He
looked upon me as being more or less in his charge, and I heard
afterwards that he had deputed three of his men who were strong
swimmers to keep an eye upon me in case my horse foundered. As
a rule the early morning is the best time to cross these rivers,
because no snow melts in the mountains during the night, when
everything is frozen, nor does it do so until the sun has been up for
some hours. Once or twice our baggage animals were greatly
delayed by the water, and on one occasion only our bedding reached
the camping ground, a pasturage dotted with tamarisk scrub. That
night I was roused more than once by some grazing pony lurching
against my bed in the darkness.
The dreary Gez gorge became wilder as we penetrated its recesses.
Here and there rocks and stones were piled one upon another in a
chaotic confusion that gave one a glimpse of the tremendous power
of ice and water, the scenery being so savage as to seem more like
a nightmare than reality. It inspired me with a kind of awe, and I am
not ashamed to own that I should have been terrified to find myself
alone in these solitudes, shut in by the lofty conglomerate hills,
above which one gained occasional glimpses of snowy peaks. The
river, beneficent and life-giving in its lower reaches, is here an agent
of destruction, with not a tree and hardly a plant on its banks; and yet
at one of the gloomiest reaches, when I was filled with a sense of
impending disaster, my mood was changed in a second by the sight
of two small birds pursuing one another in a love flight.
We had to cross several native bridges made on the cantilever
system, and always dismounted, for they swayed from side to side,
and our horses were nervous at first, even when led over them. As
the raging torrent at these points was penned into narrow limits it
swirled and eddied and foamed among the huge boulders below us,
and I was thankful that these bridges had been improved since Lord
Dunmore visited the Pamirs in 1892 and wrote that they consisted of
a couple of beams on which brushwood and large round stones were
laid.
When there were no bridges and the water was too deep for our
horses we were obliged to negotiate various passes. In these the
narrow track, with only room for one animal abreast, was often
formed of loose shale, which here and there poured down the
mountain side in big fans, the shingle rustling as it fell on to our path
and descended the precipitous cliffs to the torrent surging far below. I
did not appreciate my pony’s fondness for treading on the extreme
edge of the track and sending showers of tiny pebbles hurtling down;
but as it would have been a physical impossibility for me to have
walked up all these passes—I always descended them on foot—I
used to console myself with the reflection that our horses were by no
means anxious to commit suicide.
At the end of the gorge, dome-shaped Muztagh Ata, with its covering
of snow, stood up magnificently, seeming to block up the end of the
narrow valley, and from that moment it entered into my life, so
familiar did it become to me and so greatly did I admire it. Sandy
tracks now led us to the shallow Bulunkul Lake, more than half-filled
with sand blown from the hills that encircle it, and we halted on a
stretch of pasturage on which yaks were grazing, and were glad to
think that a critical part of our journey was safely accomplished.
It may be of interest if I give some account of how we travelled
during this tour. The rule was to rise at 5 a.m., if not earlier, and I
would hastily dress and then emerge from my tent to lay my pith-hat,
putties, gloves and stick beside the breakfast table spread in the
open. Diving back into my tent I would put the last touches to the
packing of hold-all and dressing-case, Jafar Bai and his colleague
Humayun being busy meanwhile in tying up my bedstead and
bedding in felts. While the tents were being struck we ate our
breakfast in the sharp morning air, adjusted our putties, applied face-
cream to keep our skins from cracking in the intense dryness of the
atmosphere, and then would watch our ponies, yaks or camels as
the case might be, being loaded up. These last-mentioned ungainly
creatures used to cry and protest all the time, giving their owners as
much trouble as possible before they could be induced to lie down,
and occasionally throwing off their burdens. A baby-camel being of
the party during part of our journey, its mother greatly resented being
made to work, and all the animals were shedding their winter coats,
the fur hanging on their bodies in loose, untidy patches. My chief
objection to the camel is its disagreeable odour, and I have often
wondered why an animal that is such a clean feeder should smell so
horribly.
When the loads were at last adjusted and the caravan was ready to
start, we would mount our horses, or one of our men would lead
them behind us while we walked for an hour before we began to ride.
As we had three horses between us, I usually rode half the stage on
my side-saddle if the going were good, and the other half on Tommy
with a native saddle which had a cushion strapped on to it, and I
found that the change of seat kept me from getting overtired, while
my astride habit did for either mode.
We usually marched for five hours and then halted for lunch, waiting
until our caravan had overtaken and passed us. Sattur, who
accompanied us on his pony, would unpack his tiffin basket, and we
would lie by the water, in the shade of a tree if possible, as the sun
by noon was very powerful. When the worst of the heat was over,
and our baggage animals had been given an hour’s start, we would
ride another three or four hours into camp, to revel in afternoon tea
and warm baths, I having an extra treat in the brushing out of my
hair, so hastily done up in the morning. Then would come a
consultation with Daoud as to our evening meal, and one of the store
boxes would be opened to give out everything needed for it and for
the morrow’s breakfast and lunch. After dinner we usually strolled up
and down for an hour, warmly wrapped up—for it became very cold
when the sun went down—and then turned in to dreamless
slumbers.
From Lake Bulunkul and onwards we saw a great deal of the Kirghiz,
and, though travellers differ as to their opinion of these peaceful
pastoral people, we ourselves liked them and found them most
friendly and hospitable. Their broad hairless faces and high cheek-
bones show their Mongol descent, but though akin to the yellow-
skinned, oblique-eyed Chinese, they look very different, and both
men and women have fresh ruddy complexions.
We first camped with them at a spot called “Stone Sheep-folds,” from
the presence of a roughly walled enclosure into which the flocks
were driven at night to be guarded from the wolves by the savage
Kirghiz dogs. As we rode across a wide grassy plain towards a group
of akhois, the native dwellings that look like huge bee-hives, it was
the hour of the afternoon milking, and Kirghiz women in gaily
coloured coats, long leather boots and the characteristic lofty white
headgear, were busily at work. They had tied the sheep and the
goats and the black, brown or particoloured yaks to long ropes and
let the animals go free one by one when they had been milked, a
loud chorus of bleating and grunting going on all the time. Troops of
mares, accompanied by their foals, were feeding all round the camp,
and our Badakshani horses were excited to such an extent that the
chestnut had to be blindfolded in order to quiet him; and throughout
the tour I had often from this cause an unpleasantly lively time with
my grey, which had been imperturbable when at Kashgar.
It was mid-June, but a high wind was blowing and drove the sand in
clouds from the hills, invading the little tent, in which I could not
stand upright save in the centre, and whisking up its flaps. As I could
not perform my toilet unless I fastened up the entrance, I had to
grope for everything in almost total darkness, and though the space
was extremely limited, it was surprising how easily things got mislaid.
My tent was still less desirable as a residence when it rained, as
after a while tiny streams would begin to trickle down inside at the
points where my camp furniture touched the walls, and my
belongings—most of them perforce on the ground—got damp and
clammy. Of course a large tent with talc windows is very comfortable
—with certain exceptions; but we had heard so much about the
storms that sweep over the Pamirs that we had taken only small
ones on this expedition.
At our next halt, Kuntigmas, meaning “the place that the sun cannot
reach,” I was provided with an akhoi all to myself. Indeed, I always
dwelt in these roomy “white houses” whenever possible. They are
usually eighteen feet in diameter, the same size as the Turkoman
kibitkas in the north of Persia, and the framework of willow-wood is a
trellis about four feet high, which pulls out and is placed on the
ground in a circle. To the upper edge of this a series of curved laths
are tied about a foot apart, the other end of these laths being
inserted into the holes of a thick wooden hoop that forms the top of
the dome-like erection. Large felts are now fastened with ropes over
the akhoi, leaving free the opening at the top to admit light and air—
also rain and snow on occasion—and to let out the smoke of the
fires. In case of really bad weather a felt can be drawn over the
circular opening, and again withdrawn, on the same principle as the
ventilation arrangements in some of the London theatres. A wooden
framework, often prettily carved, is placed between the two ends of
the trellis-work to serve as a doorway, and is hung with a piece of
matting and a felt or carpet. Inside, the framework is completely
covered with felts, and along the top of the trellis I noticed throughout
our tour an effective finish in the shape of a band of red felt with a
blue floriated pattern that passed half-way round the akhoi, the other
half being decorated with the same design, but with the colours
reversed.
These dwellings can be purchased for £7 (a Chinese yambu), but
those of superior quality often go up to £35 in price. The earthen
floor is beaten hard and covered with carpets, a depression being
left in the centre for the fire. Some of the old carpets were very
pleasing, with their soft madders and indigoes and greens, a
favourite design being conventionalized flowers; but alas, most of
them were badly burnt by the sparks that had leapt on to them from
the brushwood used to start the fires. The Kirghiz of to-day does not
appreciate their velvety sheen, but loves the modern Khotan
productions, with their crude scarlets, purples, yellows and magentas
all introduced into the same pattern in a series of violent colour
discords.
All travellers speak of the akhoi with esteem, and I was always
grateful for its space, and, in fine weather, for its comfort, although
during snow and rain I found that it had some drawbacks. For
example, the hole at the top let in much wet, but if the felt were
drawn across it I was deprived of light, and if I rolled up my entrance
carpet I had no privacy and was exposed to violent draughts, as the
walls were by no means airproof. The felts that covered them were
so full of holes that on a rainy day one had to use much
discrimination as to where to put one’s belongings in order to keep
them comparatively dry, and on more than one occasion I have slept
with my mackintosh drawn up over my head in order to prevent the
rain from splashing on my face during the night.
There is little in the way of “furniture” in these dwellings save
picturesquely shaped copper jugs in which water is boiled, a few
copper pots and basins used for cooking and as receptacles for milk,
and some rough wooden buckets. On one occasion we were
ushered into an akhoi to eat our lunch out of the glare of the sun,
and had ensconced ourselves on a rug, at one end of which was a
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com