JINJON
JINJON

Reputation: 1

WebODF simple file open

I'm trying to make a simple file viewing with WebODF in javascript. My code looks like this:

<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("c:\file directory\myfile.odt");
        }
        window.setTimeout(init, 0);
    </script>
</head>

When I'm running the code I'm getting an alert:

ASSERTION FAILED: odf.OdfCanvas constructor needs DOM element

Why is that happening and how can I open the odt file?

Upvotes: 0

Views: 744

Answers (1)

damitj07
damitj07

Reputation: 2919

I think the error means you need to create a div or section with id =odf and that webodf is unable to find a Dom element. Or you can create a element using document.createElement() and pass that as input to webodf.

You can refer to this answer

Upvotes: 0

Related Questions