Como abrir os ficheiros do SharePoint no Chrome/Firefox

No Internet Explorer, posso abrir ficheiros Sharepoint directamente dos seus links para que o ficheiro no Sharepoint seja actualizado automaticamente quando o gravar. Mas no Chrome, ele pede para baixar o arquivo em vez de apenas abri-lo. No Firefox, ele pode abrir o arquivo, mas ainda assim apenas transfere-lo para uma pasta temporária, em seguida, abri-lo.

Como posso abrir directamente ficheiros Sharepoint no Chrome ou no Firefox, tal como faço no Internet Explorer?

Author: Verne Jules, 2013-01-22

3 answers

A Instalação da extensão Chrome IE Tab fez o trabalho por mim.

Tem a capacidade de detectar automaticamente URLs, por isso, sempre que navego até ao nosso SharePoint, emula o Internet Explorer. Finalmente posso abrir documentos do escritório diretamente do Chrome.

Também pode instalarIETab para o FireFox.

 23
Author: Sigar Dave, 2013-01-22 10:19:04

Você pode usar web-based protocol handlers para as ligações de acordo com https://sharepoint.stackexchange.com/questions/70178/how-does-sharepoint-2013-enable-editing-of-documents-for-chrome-and-fire-fox

Basicamente, basta pré-enviar {[[0]} para os links para os seus documentos do Word hospedados no SharePoint.

 4
Author: LyphTEC, 2017-04-13 12:41:19

Graças a @LyphTEC que deu uma maneira muito interessante de abrir um arquivo de escritório no modo de edição!

Deu-me a ideia de mudar a função _DispEx que é chamada quando o utilizador clica num ficheiro para uma biblioteca de documentos. Ao hackear a função original, nós podemos abrir uma janela (para o Firefox / Chrome) e perguntar ao usuário se ele / ela quer ler somente ou editar o arquivo: enter image description here

Veja abaixo o código JavaScript que usei. Meu código é para arquivos Excel, mas pode ser modificado para trabalhar com documentos Word também:

    /**
 * 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")

Uso SP.SOD.executeOrDelayUntilEventNotified para ter a certeza que a função será executada quando core.js for carregada.

 1
Author: AymKdn, 2017-02-09 18:13:44