forked from weblabux/HelloWorlds
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.html
More file actions
41 lines (32 loc) · 1.08 KB
/
Copy pathhello.html
File metadata and controls
41 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<html>
<head>
<script src="bob.js"></script>
<script src="elisabeth.js"></script>
<title>Hello Team</title>
</head>
<body>
<script type="text/javascript">
// Note: Although this code is functionally 'correct' it leaves
// much room for refactoring. ;)
// updateText takes a string and a document fragment.
// It turns the string into a paragraph and appends the paragraph
// to the pre-defined document fragment, updating this document
// fragment as a side effect!
function updateText( string, docFragment ) {
var p, t;
p = document.createElement('p');
t = document.createTextNode(string);
p.appendChild(t);
docFragment.appendChild(p);
}
// textContent will be used to hold the paragraphs for page's content
textContent = document.createDocumentFragment();
// one by one, call all of the functions that add to the text content
updateText(elisabeth(), textContent);
updateText(bob(), textContent);
// Note: we need to add more function here for everyone to say hello.
// append the text content to the document
document.body.appendChild(textContent);
</script>
</body>
</html>