-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
38 lines (28 loc) · 1.04 KB
/
index.html
File metadata and controls
38 lines (28 loc) · 1.04 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
<!DOCTYPE html>
<html>
<head>
<title>SVGInnerHTML demo</title>
<meta charset="utf-8" />
<script src="svginnerhtml.js"></script>
<script>
alter = function () {
var svg = document.getElementsByTagName('svg')[0];
svg.innerHTML = '<rect width="100" height="60" fill="green" />'
+ '<circle cx="10" cy="19" r="20" fill="blue"></circle>'
+ '<text x="15" y="20" fill="white">hello world</text>'
+ '<g transform="translate(0, 70)"><rect width="100" height="20" fill="yellow" /></g>';
}
</script>
</head>
<body>
<svg width="100px" height="100px">
<rect width="100px" height="100px" fill="red" />
</svg>
<p>
Click the button to alter SVG contents. <a href="#" onclick="this.href='view-source:' + location.href.replace(/#/, '')">View the page's source</a> for more.
<br /><br />
<button onclick="alter()">set .innerHTML</button>
<button onclick="alert(document.getElementsByTagName('svg')[0].innerHTML)">get .innerHTML</button>
</p>
</body>
</html>