1 |
wakaba |
1.1 |
<!DOCTYPE HTML> |
2 |
|
|
<html> |
3 |
|
|
<head> |
4 |
|
|
<title>Original document — setDocument</title> |
5 |
|
|
</head> |
6 |
|
|
<body> |
7 |
|
|
|
8 |
|
|
<p><code>window.xxxxx = 12345;</code></p> |
9 |
|
|
<script> |
10 |
|
|
window.xxxxx = 12345; |
11 |
|
|
</script> |
12 |
|
|
|
13 |
|
|
<p><input type=button value=setDocument onclick=" |
14 |
wakaba |
1.3 |
window.olddoc = document; |
15 |
wakaba |
1.1 |
var doc = document.implementation.createDocument |
16 |
|
|
('http://www.w3.org/1999/xhtml', 'html', null); |
17 |
|
|
var html = doc.documentElement; |
18 |
|
|
html.appendChild (doc.createElementNS ('http://www.w3.org/1999/xhtml', 'head')) |
19 |
|
|
.appendChild (doc.createElementNS ('http://www.w3.org/1999/xhtml', 'title')) |
20 |
|
|
.textContent = 'New document'; |
21 |
|
|
var body = html.appendChild (doc.createElementNS ('http://www.w3.org/1999/xhtml', 'body')); |
22 |
|
|
body.appendChild (doc.createElementNS ('http://www.w3.org/1999/xhtml', 'p')) |
23 |
|
|
.textContent = 'New document.'; |
24 |
wakaba |
1.2 |
body.onload = "document.getElementById ('atonload').textContent += '\nonload: ' + new Date ();"; |
25 |
wakaba |
1.1 |
var button = body.appendChild (doc.createElementNS ('http://www.w3.org/1999/xhtml', 'p')) |
26 |
|
|
.appendChild (doc.createElementNS ('http://www.w3.org/1999/xhtml', 'button')); |
27 |
|
|
button.textContent = 'alert (window.xxxxx)'; |
28 |
|
|
button.onclick = 'alert (window.xxxxx)'; |
29 |
wakaba |
1.2 |
body.appendChild (document.createElementNS ('http://www.w3.org/1999/xhtml', 'pre')) |
30 |
|
|
.setAttributeNS (null, 'id', 'atonload'); |
31 |
wakaba |
1.1 |
setDocument (doc); |
32 |
|
|
"></p> |
33 |
|
|
|
34 |
|
|
</body> |
35 |
|
|
</html> |