This question is very similar to the completely updated version of the question asked here: How to call the JavaScript function from one frame to another in Chrome / Webkit with the file protocol - unfortunately, this question has never been answered.
I have an HTML page containing an SVG image in an iframe. SVG exports a JavaScript API that allows it to do useful things (reset to enlarge and center, display at "actual size"). Below the iframe, I added buttons that the user can click on this call using the functions defined in SVG.
My code is as follows:
function reset() {
document.getElementByID('iframe').contentWindow.reset();
}
It works great in Safari, Firefox, and even in IE 9 (which supports SVG - hooray!). But in Chrome this fails: the debugger tells me that:
Property 'reset' of object [object DOMWindow] is not a function.
And indeed, it seems to be true: although contentWindow is of type DOMWindow, it has no methods or fields (at least not what the debugger will show me). Even querying the "document" field does not work (gives a null value).
It seems like using the file: // protocol to port both containing HTML and containing SVG. As noted in the question I referenced above, Chrome produces the following error when trying to access contentWindow content:
Attempt to access frame with URL file://[...]/contained.svg from frame with URL file://[...]/container.html. Domains, protocols and ports must match.
, , ; , . , , : , , .
- . " Chrome - ".
?