2

I generate Html/js/svg document to be used from a local computer.

When I try to execute my javascript I get this error:

Uncaught SecurityError: Failed to read the 'contentDocument' property from 'HTMLObjectElement': Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match

I found a stackoverflow answer about it: here

I do not know what to put into document.domain as my html page is a local file.

the html page

<!DOCTYPE html>
<html>
    <head>
      <script type='text/javascript' src='js/test.js'></script>
    </head>
    <body>
        <object id='test' data='test.svg' type='image/svg+xml'>
        Your browser doesn't support SVG
        </object>
    </body>
</html>

the javascript code is simple:

window.addEventListener('load',function(){
  const object        = document.getElementById('test');
  const svgdoc        = object.contentDocument;
 ...
}, false);

My script works fine with firefox 31.5.0 but not with google-chrome 41.0.

Thanks for your help

Community
  • 1
  • 1
bioinfornatics
  • 1,749
  • 3
  • 17
  • 36

0 Answers0