I have a page with an svg tag. The page has a button called "Preview" which on clicking should open a new window with the image (svg).
Below is a piece of code which works in Chrome/Firefox but not in IE (I'm using IE 9- IE9 standards mode)
var w = window.open();
var svg = $('#chart');
var svgPrint = svg.cloneNode(true);
svgPrint.setAttribute('xmlns','http://www.w3.org/2000/svg');
w.document.body.appendChild(svgPrint);
Any suggestions would be highly appreciated.
Thanks.
about:blank
is run in Quirks mode, which doesn't supportsvg
. – Thirtytwowindow
you open is more likely to run in Quirks mode, since it doesn't have a doctype declaration... Just test it by opening a real document in it. – ThirtytwoException thrown and not caught
). But this code has nothing to do withtry..catch
?! Also loading a real page to a newly opened window doesn't remove this error. Settingw.document.body.innerHTML = '...'
seems to work. When enclosingappendChild()
withintry..catch
, the error message isHierarchyRequestError
, which means, that "The node cannot be inserted at the requested location." This smells a big bug in IE... – Thirtytwo