【问题标题】:How to open SharePoint files in Chrome/Firefox如何在 Chrome/Firefox 中打开 SharePoint 文件
【发布时间】:2013-01-05 11:39:49
【问题描述】:

在 Internet Explorer 中,我可以直接从它们的链接打开 Sharepoint 文件,这样 Sharepoint 中的文件在我保存时会自动更新。但在 Chrome 中,它要求下载文件而不是仅仅打开它。在 Firefox 中,它可以打开文件,但仍然只是将其下载到临时文件夹然后打开它。

如何像在 Internet Explorer 中一样在 Chrome 或 Firefox 中直接打开 Sharepoint 文件?

【问题讨论】:

  • 所有这些软件的版本是什么? (SP、Office、Chrome、Windows 等)

标签: internet-explorer google-chrome sharepoint firefox


【解决方案1】:

安装 Chrome 扩展程序 IE Tab 为我完成了这项工作。

它能够自动检测 URL,因此每当我浏览到我们的 SharePoint 时,它都会模拟 Internet Explorer。终于可以直接从 Chrome 中打开 Office 文档了。

您也可以为 FireFox 安装 IETab

【讨论】:

  • 我认为这个 IETab 插件永远不会适用于 Mac 操作系统。因为它的开发者拒绝看到这里。 forums.mozillazine.org/viewtopic.php?f=8&t=861555
  • 如果你想在 mac 上下载 IE,那么这里有一个链接,但请先确保安全pure-mac.com/webb.html
  • 可能,但我提供了我个人使用过的答案
  • 不幸的是,我发现它不适用于自动结帐签入过程。
  • 我不确定
【解决方案2】:

您可以根据 https://sharepoint.stackexchange.com/questions/70178/how-does-sharepoint-2013-enable-editing-of-documents-for-chrome-and-fire-fox 对链接使用基于 Web 的协议处理程序

基本上,只需将ms-word:ofe|u| 添加到指向您的 SharePoint 托管 Word 文档的链接。

【讨论】:

    【解决方案3】:

    感谢@LyphTEC,它提供了一种非常有趣的方式来在编辑模式下打开 Office 文件!

    它让我想到了更改函数_DispEx,当用户单击文件进入文档库时调用该函数。通过破解原始功能,我们可以让他们打开一个对话框(用于 Firefox/Chrome)并询问用户他/她是否想要只读或编辑文件:

    请看下面我使用的 JavaScript 代码。我的代码适用于 Excel 文件,但也可以修改它以处理 Word 文档:

        /**
     * fix problem with Excel documents on Firefox/Chrome (see https://blog.kodono.info/wordpress/2017/02/09/how-to-open-an-excel-document-from-sharepoint-files-into-chromefirefox-in-readonlyedit-mode/)
     * @param  {HTMLElement} p the <A> element
     * @param  {HTMLEvent} a the click event
     * @param  {Boolean} h TRUE
     * @param  {Boolean} e FALSE
     * @param  {Boolean} g FALSE
     * @param  {Strin} k the ActiveX command (e.g. "SharePoint.OpenDocuments.3")
     * @param  {Number} c 0
     * @param  {String} o the activeX command, here we look at "SharePoint.OpenDocuments"
     * @param  {String} m
     * @param  {String} b the replacement URL to the xslviewer
     */
    var bak_DispEx;
    var modalOpenDocument; // it will be use with the modal
    SP.SOD.executeOrDelayUntilEventNotified(function() {
      bak_DispEx = _DispEx;
      _DispEx=function(p, a, h, e, g, k, c, o, m, b, j, l, i, f, d) {
        // if o==="SharePoint.OpenDocuments" && !IsClientAppInstalled(o)
        // in that case we want to open ask the user if he/she wants to readonly or edit the file
        var fileURL = b.replace(/.*_layouts\/xlviewer\.aspx\?id=(.*)/, "$1");
        if (o === "SharePoint.OpenDocuments" && !IsClientAppInstalled(o) && /\.xlsx?$/.test(fileURL)) {
          // if the URL doesn't start with http
          if (!/^http/.test(fileURL)) {
            fileURL = window.location.protocol + "//" + window.location.host + fileURL;
          }
          var ohtml = document.createElement('div');
          ohtml.style.padding = "10px";
          ohtml.style.display = "inline-block";
          ohtml.style.width = "200px";
          ohtml.style.width = "200px";
          ohtml.innerHTML = '<style>'
                          + '.opendocument_button { background-color:#fdfdfd; border:1px solid #ababab; color:#444; display:inline-block; padding: 7px 10px; }'
                          + '.opendocument_button:hover { box-shadow: none }'
                          + '#opendocument_readonly,#opendocument_edit { float:none; font-size: 100%; line-height: 1.15; margin: 0; overflow: visible; box-sizing: border-box; padding: 0; height:auto }'
                          + '.opendocument_ul { list-style-type:none;margin-top:10px;margin-bottom:10px;padding-top:0;padding-bottom:0 }'
                          + '</style>'
                          + 'You are about to open:'
                          + '<ul class="opendocument_ul">'
                          + '  <li>Name: <b>'+fileURL.split("/").slice(-1)+'</b></li>'
                          + '  <li>From: <b>'+window.location.hostname+'</b></li>'
                          + '</ul>'
                          + 'How would like to open this file?'
                          + '<ul class="opendocument_ul">'
                          + '  <li><label><input type="radio" name="opendocument_choices" id="opendocument_readonly" checked> Read Only</label></li>'
                          + '  <li><label><input type="radio" name="opendocument_choices" id="opendocument_edit"> Edit</label></li>'
                          + '</ul>'
                          + '<div style="text-align: center;margin-top: 20px;"><button type="button" class="opendocument_button" style="background-color: #2d9f2d;color: #fff;" onclick="modalOpenDocument.close(document.getElementById(\'opendocument_edit\').checked)">Open</button> <button type="button" class="opendocument_button" style="margin-left:10px" onclick="modalOpenDocument.close(-1)">Cancel</button></div>';
          // show the modal
          modalOpenDocument=SP.UI.ModalDialog.showModalDialog({
            html:ohtml,
            dialogReturnValueCallback:function(ret) {
              if (ret!==-1) {
                if (ret === true) { // edit
                  // reformat the fileURL
                  var ext;
                  if (/\.xlsx?$/.test(b)) ext = "ms-excel";
                  if (/\.docx?$/.test(b)) ext = "ms-word"; // not currently supported
                  fileURL = ext + ":ofe|u|" + fileURL;
                }
                window.location.href = fileURL; // open the file
              }
            }
          });
          a.preventDefault();
          a.stopImmediatePropagation()
          a.cancelBubble = true;
          a.returnValue = false;
          return false;
        }
        return bak_DispEx.apply(this, arguments);
      }
    }, "sp.scriptloaded-core.js")
    

    我使用SP.SOD.executeOrDelayUntilEventNotified 来确保函数会在core.js 被加载时执行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多