Permission to obtain SVGDocument.getElementById property denied
Hello i am trying to make an application where i can control an SVG image from another browser window. The communication between windows is ok, and my receiver gets the info, but when i try to access to the SVG file to change something firebug tells me that i don't have permission to acess the svg file:S
to simplify, my SVG file is embebed like this:
And the way i test the access to it:
window.onload = function()
{
svgdoc = document.car1.getSVGDocument();
var door = svgdoc.getElementById("door1");
door.setAttribute("stroke-opacity",0.4);
}
What is strange is that it lets me get the SVG document... but then i can't access to the "door", wich is an element of the SVG.
Ah... and i don't have any problem with IE... it works fine there:S Can anybody help me???pleaseeeeee:)
Comments
Can you show me actual files
Can you show me actual files that have this problem? Or at least fully describe them here like:
I don't know what car1 is, I don't know what door1 is, I don't know in what context you're running the onload. If you can put a couple files (HTML and SVG) on a website somewhere I can help you debug.
Also, can you copy the error
Also, can you copy the error from Firebug? I've seen Permission Denied errors from it before that don't refer directly to the document loaded in the browser window (maybe referring to chrome or another addon).
iirc you can just right-click and copy on the message itself.
Ok, here's my SVG file. I
Ok, here's my SVG file. I have done what i wanted with the method of window.parent. although i believe is not the best way:S
<?xml version="1.0" standalone="no"?>
function puerta_click(evt) { var puerta =
evt.target; var currentRadius =puerta.getAttribute("stroke-opacity"); if
(currentRadius == 0) puerta.setAttribute("stroke-opacity",0.4); else
puerta.setAttribute("stroke-opacity",0); }
function coche_click(evt) { var coche =
evt.target; var current =coche.getAttribute("stroke-opacity"); if (current
== 0) coche.setAttribute("stroke-opacity",0.3); else
coche.setAttribute("stroke-opacity",0); }
------------------------------------------------
and here's my html:
var svgDocument = null;
var svgWindow = null;
var svgRoot = null;
function InitHTML()
{
var embed = document.getElementById('coche1');
try
{
svgDocument = embed.getSVGDocument();
}
catch(exception)
{
alert('The GetSVGDocument interface is not supported');
}
if (svgDocument && svgDocument.defaultView) // try the W3C standard way first
{
svgWindow = svgDocument.defaultView;
}
else if (embed.window)
{
svgWindow = embed.window;
}
else
{
try
{
svgDocument = embed.getWindow();
}
catch(exception)
{
alert('The DocumentView interface is not supported\r\n' + 'Non-W3C standard methods of obtaining \'window\' also failed');
}
}
if ( svgDocument )
{
svgRoot = svgDocument.documentElement;
}
}
function ChangeStroke1()
{
SetStrokeColor1();
}
function ChangeStroke2()
{
SetStrokeColor2();
}
function der()
{
derecha();
}
function izq()
{
izquierda();
}
function cab()
{
cabina();
}
function prueba()
{
var targetElement = svgDocument.getElementById('Puerta1');
targetElement.setAttributeNS(null, 'stroke-opacity', 0.4);
}
...
So... what else???:)
Post new comment