I have some code (below) where I get a file via jQuery $get method.
In Firefox it works, but in Safari and Chrome I get the following
error:
"Unsafe JavaScript attempt to access frame with URL data:image/svg
+xml, <svg xmlns:svg='
http://www.w3.org/2000/svg' xmlns='http://
www.w3.org/2000/svg' viewBox='0 0 200 100' width='200px'
height='100px'><rect x='60' y='20' height='60' width='60'
style='stroke:none; fill:#00ff00;fill-opacity: 0.5;' /> </svg> from
frame with URL
http://localhost:8081/MISDashboard/WebContent/Category.html.
Domains, protocols and ports must match."
Code:
function loadSVG(pSVG)
{
1. var svg = document.createElement('object', true);
2. svg.setAttribute('data', 'data:image/svg+xml,' + pSVG);
3. svg.setAttribute('type', 'image/svg+xml');
4.
5. svg.addEventListener('load', function() {
6. $("#chartDiv").html(addedRoot);
7. }, false);
8.
9. addedRoot = svg;
10. svgweb.appendChild(svg, document.body);
}
If I try "svg.setAttribute('data', pSVG);" instead of line 2. (i.e.
without the "'data:image/svg+xml,' + " bit) it doesn't work in any
browser.
Thanks for any help on this.