The following works in Firefox 4, but not Chrome 10:
In case someone stumbles accross this page. Here is a simpler way to use an HTTP request object to fetch the svg file:
window
.fetch('/assets/ciphers.svg')
.then(
function (response) {
return response.text();
}
).then(
function (body) {
var div = document.createElement('div');
div.innerHTML = body;
while (div.children.length > 0) {
document.head.appendChild(div.children[0]);
}
}
);
The trick is in the following line (either you use window.fetch or xmlHttpRequest or whatever):
var div = document.createElement('div');
div.innerHTML = body;
while (div.children.length > 0) {
document.head.appendChild(div.children[0]);
}