简体   繁体   中英

MS Office Firefox Plugin (NPAPI)

I am having trouble getting a Microsoft Office document to open in FireFox - using Microsoft's Office 2010 plugin.

Please see http://msdn.microsoft.com/en-us/library/ff407576.aspx

I am trying it with the following html document in firefox. I have confirmed that the MS Office 2010 plugin is installed.

    <doctype html>
    <html>
    <head>
    <script>
    function OpenWebDavDocument(url, extension) {
        debugger;
        var hownowPlugin = document.getElementById("winFirefoxPlugin");
        hownowPlugin.EditDocument2(url, null)
    }
    </script>
    </head>
    <body>
        <object id="winFirefoxPlugin" type=”application/x-sharepoint">
        <a href="#" onclick="OpenWebDavDocument('bfd42001/hownow/files/Records/12182', 'xlsx')" style="">Excel Doc</a>
        <a href="#" onclick="OpenWebDavDocument('hbfd42001/hownow/files/Records/8924', 'docx')" style="">Word Doc</a>
    </body>
    </html>

I am getting the following error when inspecting in FireBug:

hownowPlugin.EditDocument2 is not a function

Can anyone please point out where I am going wrong?

There was one additional change I made to get the link to work.

Currently, you have:

hownowPlugin.EditDocument2(url, null);

I removed the 2:

hownowPlugin.EditDocument(url, null);

Documentation for the FFWinPlugin can be found at http://msdn.microsoft.com/en-us/library/ff407576.aspx .

I'm doing a similar project where I need to support multiple browsers. My original edit code was from Milton ( http://milton.io/index.html ). It only worked in IE. Pooling together the IE code and the Firefox code, I was able to come up with this.

<script type="text/javascript">
    var fNewDoc = false;
    var EditDocumentButton = null;
    try {
        EditDocumentButton = new ActiveXObject('SharePoint.OpenDocuments.3');
        if (EditDocumentButton != null) { fNewDoc = true; }
    } catch(e) {}

    var L_EditDocumentError_Text = "Editing not supported.";
    var L_EditDocumentRuntimeError_Text = "Sorry, couldn't open the document.";

    function editDocument(strDocument) {
        if (fNewDoc) {
            if (!EditDocumentButton.EditDocument(strDocument)) {
                alert(L_EditDocumentRuntimeError_Text);
            }
        } else {
            try {
                var hownowPlugin = document.getElementById("winFirefoxPlugin");
                hownowPlugin.EditDocument(strDocument, null);
            } catch (e) { alert(L_EditDocumentError_Text); }
        }
    }
</script>
<object id="winFirefoxPlugin" type="application/x-sharepoint" width="0" height="0" style="visibility: hidden;"></object>

By the way, i had trouble making this work in Firefox. One thing to mention, is the path to the document needs to be absolute and not relative.

    var hownowPlugin = document.getElementById("winFirefoxPlugin");
    var version = hownowPlugin.GetOfficeVersion();
    hownowPlugin.EditDocument("http://example.com/word.doc", version);

I don't have that plugin, but maybe it doesn't work because of a typo (error on the Microsoft page). You have

type=”application/x-sharepoint"

instead of

type="application/x-sharepoint"

(first quote)

Also give ! in the <!doctype html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM