-
Notifications
You must be signed in to change notification settings - Fork 30
/
example.html
42 lines (38 loc) · 1.44 KB
/
example.html
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
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Marked-Up SVG World Map Example</title>
<meta name="author" content="Ben Hodgson">
</head>
<body>
<embed src="map.svg" type="image/svg+xml" id="world" width="408" height="230">
<script type="text/javascript">
(function () {
var world = document.getElementById("world");
if (location.protocol == "file:") {
var warningDiv = document.createElement("div");
warningDiv.style.color = "red";
document.body.insertBefore(warningDiv, world);
warningDiv.textContent = "Due to restrictions imposed by the " +
"same-origin policy, this demo probably won't work when " +
"accessed using the file:// URI scheme. If you're having " +
"trouble getting it to work, try accessing it over HTTP.";
}
world.addEventListener("load", function () {
var doc = world.getSVGDocument();
// Colour Canada red
doc.querySelector("[cc=ca]").style.fill = "red";
// Alert the ISO3166 code of clicked countries
doc.addEventListener("click", function (e) {
var target = e.target,
cc = target.getAttribute("cc") || target.parentElement.getAttribute("cc");
if (cc) {
alert("My country code is " + cc);
}
});
});
}());
</script>
</body>
</html>