Reputation: 635
I want to use WebODF in it's simplest form: http://www.webodf.org/start/ Just to show an ODT document in a webbrowser. I've read all these posts: https://stackoverflow.com/search?q=webODF before I "duplicated" the question.
I have the followings in the same local folder (c:\Data): - webODTTest.html - Try.odt - webodf.js
according to the link above, the ODTTest.html looks like this:
<html>
<head>
<script src="webodf.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function init() {
var odfelement = document.getElementById("odf"),
odfcanvas = new odf.OdfCanvas(odfelement);
odfcanvas.load("Try.odt");
}
window.setTimeout(init, 0);
</script>
</head>
<body>
<div id="odf"></div>
</body>
</html>
When I try to load the html in a browser, the script seems to start, because it shows: "LoadingTry.odt...". But then at this point it stops, and doesn't load/show the Try.odt.
What am I missing?
Upvotes: 0
Views: 537
Reputation: 3151
Chrome 52 reported:
XMLHttpRequest cannot load file:///C:/data/Try.odt. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
It appears that WebODF launches an XMLHttpRequest to retrieve Try.odt, but this isn't supported with local files (file://) by just double-clicking the html page for security reasons. You can launch Chrome with --allow-file-access-from-files
parameter, so WebODF can access Try.odt
Internet Explorer 11 doesn't work either.
Firefox 45.0.2 works though because Try.odt is in the same folder with the other files and it appears that it allows that by default.
Every browser will work however if you server the files through a web server via http://
Upvotes: 0