0

In a SharePoint project I am working on that shows files, we have a button to open the SPFile that the user is seeing in office.
Currently, the button is working for IE only. I have to make it available for chrome and firefox also (currently it is just saving the file instead of opening it in these browsers).
I know this is possible because when you open the file from SharePoint home page it does open in office.
I have searched for solutions and found one that uses Application URL protocol for word here but unfortunately that doesn't work for my case because I need to know when the user closes the document to refresh the age to show changes :(

here is the code we are using: (note that this link is called through javascript

<a id="OfficeUrl" onclick="g_varSkipRefreshOnFocus = 0;fromOffice = true;if(isIE){window.onfocus = RefreshOnFocus;browseris.ie=true;}DispEx(this, event, 'TRUE', 'FALSE', 'FALSE', 'SharePoint.OpenDocuments.3', '1', 'SharePoint.OpenDocuments', '', '', $('[id$=CheckedOutUserHidden]').val(), $('[id$=UserIdHidden]').val(), '0', '0', '0x7fffffffffffffff', '', '');if(!isIE){window.onfocus = RefreshOnFocus;}g_varSkipRefreshOnFocus = 0;return false;" href="" style="display: none;"></a>

[Edit] I forgot to tell you that we are referencing SP.CORE.js and SP.INIT.js (however they seem different from the ones located in \layouts\15\sp.init.js- looks like they are from SharePoint-2010 because the version of sp.init.js is 14.0.4762)

Community
  • 1
  • 1
PhpLou
  • 430
  • 3
  • 16

1 Answers1

0

I was able to make it work in chrome. What I did is that I used the \_layouts\15\CORE.js and \_layouts\15\INIT.js and I surrounded the a tag with

<div ctxname="ctx1" app="ms-word">
    <a id="OfficeUrl" onclick="g_varSkipRefreshOnFocus = 0;fromOffice = true;if(isIE){window.onfocus = RefreshOnFocus;browseris.ie=true;}DispEx(this, event, 'TRUE', 'FALSE', 'FALSE', 'SharePoint.OpenDocuments.3', '1', 'SharePoint.OpenDocuments', '', '', $('[id$=CheckedOutUserHidden]').val(), $('[id$=UserIdHidden]').val(), '0', '0', '0x7fffffffffffffff', '', '');if(!isIE){window.onfocus = RefreshOnFocus;}g_varSkipRefreshOnFocus = 0;return false;" href="" style="display: none;"></a>
</div>

Hope it helps someone

I now need to know how to do it for firefox (looks like sharepoint does not support it? because it does not open from sharepoint).

PhpLou
  • 430
  • 3
  • 16