AK
unread,Apr 12, 2012, 8:25:20 PM4/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to SVG Web
I'm creating svg which is downloaded via cross domain request.
Here is a snippet
//parse svg dom from string
var svg_dom = $.xmlDOM(response.data).children();
//create svg element
var s = document.createElementNS(svgns, 'svg');
s.setAttribute('width', svg_dom.attr('width'));
s.setAttribute('height', svg_dom.attr('height'));
//copy parsed dom to svg element
function copyTree(jt, st){
jt.children().each(function(){
var tag_name = this.tagName;
var e = document.createElementNS(svgns, tag_name);
$.each(this.attributes, function(k, a) {
if (a.nodeName == 'class') {
...
} else e.setAttribute(a.nodeName, a.nodeValue);
});
copyTree($(this), e);
st.appendChild(e);
if ($(this).text() !== undefined && $(this).text().length > 0 &&
$(this).children().length === 0) {
var text = document.createTextNode($(this).text(), true);
e.appendChild(text);
}
});
}
copyTree(svg_dom, s);
//init onload
window.addEventListener('SVGLoad', function() {
init();
}, false)
//append svg element
svgweb.appendChild(s, document.getElementById(svg_id));
But on IE8 (probably IE7 as well) jquery selectors do not work on s.
I understand that the reason is that jQuery uses getElementsByTagName
instead of getElementsByTagNameNS
Do anybody knows the workaround for the issue.
Probably someone has redefined $.find to work with namespaces, and
could share his experience?
Thanks